Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boundary screen #1462

Open
wants to merge 16 commits into
base: console-develop-v0.3
Choose a base branch
from
Open

Boundary screen #1462

wants to merge 16 commits into from

Conversation

abishekTa-egov
Copy link
Contributor

@abishekTa-egov abishekTa-egov commented Oct 7, 2024

Debugged the error , now displays for large data

Summary by CodeRabbit

  • New Features

    • Introduced the CampaignBoundary component for enhanced user interaction.
    • Added new CSS classes for improved layout and clickable elements.
    • Implemented a new card section in the Summary Screen for campaign management.
    • Added a new SubBoundaryView component for displaying geographical data.
    • Introduced a new loading state in the CampaignDetails component for better user experience.
  • Bug Fixes

    • Updated CSS stylesheet link to the latest version for improved styling consistency.
  • Documentation

    • Added a hierarchical JSON data structure for geographical entities related to the "MICROPLAN" system.
  • Style

    • Minor formatting changes in HTML files for better readability.
  • Removed Features

    • Removed the HeaderPlusThreeInput and ThreeInputComp components as part of the cleanup process.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request includes several updates across multiple files related to the micro-ui project. Key changes involve updating the version of the @egovernments/digit-ui-css stylesheet in HTML files, adding new CSS classes in the microplan.scss, and introducing new React components such as CampaignBoundary and SubBoundaryView. Additionally, modifications to existing components like CampaignDetails enhance their interactivity and state management. A new JSON data structure representing geographical entities is also added, supporting the overall functionality of the application.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/example/public/index.html Updated stylesheet link from 1.0.72-campaign to 1.0.73-campaign.
health/micro-ui/web/public/index.html Updated stylesheet link from 1.0.72-campaign to 1.0.73-campaign and removed a newline.
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss Added new classes: .subBoundarycomp-container and .view-more.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/Module.js Added CampaignBoundary to componentsToRegister.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignBoundary.js Introduced new CampaignBoundary component with state management and rendering logic.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignDetails.js Added useEffect for state changes and a loading state check.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/subBoundaryView.js Introduced new SubBoundaryView component for rendering items conditionally.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SummaryScreen.js Added new card for CampaignBoundary and navigation item card9.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js Added a new route for CampaignBoundary.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/sample.js Introduced a new JSON structure for geographical entities.
health/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/InboxSearchLinks.js Added console logs for debugging and updated useEffect to filter links based on user roles.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/HeaderPlusThreeInput.js Removed the HeaderPlusThreeInput component.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/ThreeInputComp.js Removed the ThreeInputComp component.

Possibly related PRs

  • setup master screen enhancement  #1387: Updates the stylesheet link in the HTML file for the @egovernments/digit-ui-components package.
  • Boundary screen #1451: Changes the version of the @egovernments/digit-ui-css package stylesheet from 1.0.72-campaign to 1.0.73-campaign.
  • Assumptions #1457: Modifies the index.html file to update the @egovernments/digit-ui-css stylesheet version.
  • SN 261 #1460: Updates the stylesheet link for the @egovernments/digit-ui-css package, changing the version from 1.8.2-beta.34 to 1.8.2-beta.35.

Suggested reviewers

  • nipunarora-eGov

🐰 In the meadow, changes bloom,
New styles and components make room.
With boundaries set and data in play,
The micro-ui hops into a brighter day!
Let's celebrate this code delight,
As we code and create, our future's bright! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 26

🧹 Outside diff range comments (5)
micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/InboxSearchLinks.js (1)

Line range hint 1-43: Overall component structure and logic look good.

The InboxSearchLinks component's structure and logic appear to be well-implemented. The filtering of links based on user roles and the rendering of these links are correctly handled. However, please address the issues with the console.log statements as mentioned in the previous comments.

Additionally, consider the following suggestions to improve code quality:

  1. Use consistent naming conventions for variables (e.g., linksToShow vs linksToshow).
  2. Consider adding PropTypes for better type checking and documentation of the component's props.
  3. The useEffect hook could potentially have a dependency on links and userRoles. Review if these should be added to the dependency array.

Would you like assistance in implementing any of these suggestions?

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignDetails.js (4)

Line range hint 24-31: Potential infinite re-render due to missing dependency array in useEffect

The second useEffect hook lacks a dependency array, causing it to execute after every render. Since it updates the state variable executionCount, each update triggers a re-render, which in turn calls the useEffect again. This creates a loop that continues until executionCount reaches 5, potentially leading to performance issues.

To prevent unnecessary re-renders, include a dependency array with executionCount:

 useEffect(() => {
   if (executionCount < 5) {
     onSelect(customProps.name, {
       distributionStrat, disease, campaignType,
     });
     setExecutionCount((prevCount) => prevCount + 1);
   }
- });
+ }, [executionCount]);

Line range hint 24-31: Unclear necessity of multiple onSelect calls

Calling onSelect up to five times might not be necessary and could indicate an underlying issue with state initialization or data fetching. This could lead to unintended side effects or performance overhead.

Consider reviewing the logic to determine if multiple calls are required. If the goal is to ensure onSelect is called once after data initialization, you might:

  • Remove the executionCount logic and control the effect with a proper dependency array.
  • Ensure that onSelect is only called when the relevant data is available.

For example:

 useEffect(() => {
-  if (executionCount < 5) {
-    onSelect(customProps.name, {
-      distributionStrat, disease, campaignType,
-    });
-    setExecutionCount((prevCount) => prevCount + 1);
-  }
- }, []);
+  if (data && !isLoading) {
+    onSelect(customProps.name, {
+      distributionStrat, disease, campaignType,
+    });
+  }
+}, [data, isLoading, distributionStrat, disease, campaignType]);

Line range hint 19-22: Redundant onSelect calls in multiple useEffect hooks

Both useEffect hooks call onSelect when distributionStrat, disease, or campaignType change. This could lead to duplicate calls and potential side effects.

Consider consolidating the onSelect calls into a single useEffect hook to simplify the logic and prevent redundancy:

 useEffect(() => {
-  onSelect(customProps.name, {
-    distributionStrat, disease, campaignType,
-  });
-}, [distributionStrat, disease, campaignType]);

-useEffect(() => {
-  if (executionCount < 5) {
-    onSelect(customProps.name, {
-      distributionStrat, disease, campaignType,
-    });
-    setExecutionCount((prevCount) => prevCount + 1);
-  }
-}, [executionCount]);
+  if (executionCount < 5) {
+    onSelect(customProps.name, {
+      distributionStrat, disease, campaignType,
+    });
+    setExecutionCount((prevCount) => prevCount + 1);
+  }
+}, [distributionStrat, disease, campaignType, executionCount]);

Line range hint 77-97: Enhance accessibility for Dropdown components

The Dropdown components for selecting disease, campaign type, and distribution strategy do not include aria-label or aria-labelledby attributes. This may affect users relying on assistive technologies.

To improve accessibility, add appropriate aria-label attributes:

 <Dropdown
   style={{ width: "40rem", paddingBottom: "1rem" }}
   t={t}
   option={data?.diseases}
   optionKey={"code"}
   selected={disease}
   select={(value) => {
     setDisease(value);
   }}
   disabled={isFreezed}
+  aria-label={t("HCM_DISEASE_TYPE")}
 />

 /* Apply similar changes to the other Dropdown components */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 66ace5c and d928ebf.

⛔ Files ignored due to path filters (1)
  • health/micro-ui/web/micro-ui-internals/packages/css/package.json is excluded by !**/*.json
📒 Files selected for processing (11)
  • health/micro-ui/web/micro-ui-internals/example/public/index.html (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/Module.js (2 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignBoundary.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignDetails.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/subBoundaryView.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SummaryScreen.js (2 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js (2 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/sample.js (1 hunks)
  • health/micro-ui/web/public/index.html (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/InboxSearchLinks.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/Module.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignBoundary.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignDetails.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/subBoundaryView.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SummaryScreen.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/sample.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/InboxSearchLinks.js (1)

Pattern **/*.js: check

📓 Learnings (1)
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss (1)
Learnt from: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#876
File: micro-ui/web/micro-ui-internals/packages/css/src/components/microplanning.scss:1940-2392
Timestamp: 2024-06-14T14:10:38.086Z
Learning: Classes related to interactive elements in the microplan preview section are mostly passed to Higher Order Components (HOCs), and ARIA attributes for non-HOC elements will be managed directly by adding them where necessary.
🪛 Biome
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignBoundary.js

[error] 726-728: There is a suspicious semicolon in the JSX element.

This is usually the result of a typo or some refactor gone wrong.
Remove the semicolon, or move it inside a JSX element.

(lint/suspicious/noSuspiciousSemicolonInJsx)


[error] 751-754: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)


[error] 771-774: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)


[error] 606-606: This let declares a variable that is only assigned once.

'parents' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 607-607: This let declares a variable that is only assigned once.

'parent_group' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 666-666: This let declares a variable that is only assigned once.

'bH' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 668-668: This let declares a variable that is only assigned once.

'dic' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 671-671: This let declares a variable that is only assigned once.

'bType' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 672-672: This let declares a variable that is only assigned once.

'parent' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js

[error] 154-154: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)

🔇 Additional comments (11)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/subBoundaryView.js (2)

8-40: Component structure and conditional rendering look good.

The component's structure is well-organized, and the conditional rendering based on the arr prop is implemented correctly. The use of the Card, HeaderComp, and Chip components is appropriate for the intended functionality.


46-46: Default export looks good.

The component is correctly exported as the default export, which follows common React practices.

health/micro-ui/web/public/index.html (2)

40-40: LGTM. Minor formatting change.

The removal of the newline character before the closing tag is a minor formatting change that doesn't affect functionality.


15-15: LGTM. Verify consistency of CSS version update.

The update of the @egovernments/digit-ui-css package from version 1.0.72-campaign to 1.0.73-campaign looks good. This change likely introduces new styles or fixes for the application.

Please ensure this version update is consistent with other parts of the application. Run the following script to check for any other occurrences of the old version:

✅ Verification successful

CSS version update verified successfully.

The update to the @egovernments/digit-ui-css package is consistent across the application, with no remaining instances of the old version.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other occurrences of the old CSS version

# Test: Search for the old version string. Expect: No results.
rg --type html '1\.0\.72-campaign'

Length of output: 36

health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss (1)

106-111: Consider accessibility for the .view-more element.

Based on previous learnings, it's important to ensure proper accessibility for interactive elements. If the element using the .view-more class is not wrapped in a Higher Order Component (HOC), consider adding appropriate ARIA attributes directly to enhance accessibility.

To help verify the usage and accessibility of the .view-more class, you can run the following script:

This script will help identify where the .view-more class is used and whether ARIA attributes are present in those locations.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/Module.js (2)

18-18: LGTM: New import statement for CampaignBoundary

The import statement for the CampaignBoundary component is correctly added and follows the existing import pattern in the file. This aligns with the PR objective of enhancing the boundary screen functionality.


Line range hint 1-78: Summary: CampaignBoundary component successfully integrated

The changes in this file successfully integrate the new CampaignBoundary component into the Microplan module. The component is properly imported and registered, allowing it to be used within the module. These changes align with the PR objective of enhancing the boundary screen functionality for large datasets.

To ensure the new component works as intended:

This script will help verify that the CampaignBoundary component is being used in other parts of the codebase and that there are no remaining TODO comments related to its implementation.

✅ Verification successful

Verification Complete: CampaignBoundary Integration Validated

The CampaignBoundary component has been successfully integrated into the Microplan module and is utilized appropriately across the codebase. No TODO comments related to CampaignBoundary were found, ensuring that there are no pending tasks or unresolved issues.

  • CampaignBoundary is properly imported and registered in Module.js.
  • The component is used in SummaryScreen.js and employee/index.js without any issues.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of CampaignBoundary component in other files

# Test: Search for CampaignBoundary usage
echo "Searching for CampaignBoundary usage:"
rg --type js "CampaignBoundary"

# Test: Check if there are any TODO comments related to CampaignBoundary
echo "Checking for TODO comments related to CampaignBoundary:"
rg --type js "TODO.*CampaignBoundary"

Length of output: 1319

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js (1)

9-9: LGTM: New import statement is correctly implemented.

The import statement for CampaignBoundary is properly formatted and follows React component naming conventions.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/SummaryScreen.js (2)

470-474: LGTM! Navigation item properly added.

The new navigation item for the Campaign Boundary card is correctly added and follows the existing structure. It's properly linked to the new card9, maintaining consistency in the navigation setup.


Line range hint 1-524: Overall changes look good and well-integrated.

The modifications to add the Campaign Boundary feature are focused and well-integrated into the existing structure. The new card and navigation item are properly added without disrupting the current functionality.

A few suggestions for further improvement:

  1. Consider adding comments to explain the purpose of the new CampaignBoundary component for better code documentation.
  2. Ensure that the CampaignBoundary component is properly implemented and tested (in its separate file) to handle the customProps it receives.
  3. Update any relevant documentation or README files to reflect the addition of this new feature.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignDetails.js (1)

68-69: Unnecessary blank lines affecting code readability

There are extra blank lines at lines 68 and 69, which may reduce code readability.

While this doesn't affect functionality, removing unnecessary blank lines can improve code clarity.

@@ -18,7 +18,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].72-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].73-campaign/dist/index.css" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Multiple CSS Versions Detected: Potential for Conflicts

The file health/micro-ui/web/micro-ui-internals/example/public/index.html imports multiple versions of @egovernments/digit-ui-css, including:

  • 1.0.50-microplan
  • 1.0.73-campaign
  • 1.5.41
  • 1.8.0-alpha.6
  • 1.8.2-beta.11

Using multiple CSS versions can lead to style conflicts, increased load times, and maintenance challenges.

Recommended Actions:

  • Consolidate CSS imports to a single, consistent version where possible.
  • Review the necessity of each CSS version and update all imports to the latest stable release to ensure uniform styling across the application.
🔗 Analysis chain

LGTM: CSS version update approved.

The update of the @egovernments/digit-ui-css package from version 1.0.72-campaign to 1.0.73-campaign looks good. This minor version bump likely includes small improvements or bug fixes.

However, I'd like to bring attention to a few points:

  1. Ensure that this CSS update doesn't introduce any unexpected visual changes or breaking styles in the application.
  2. Consider reviewing and potentially consolidating the multiple CSS imports from various sources and versions throughout this file. This could help prevent potential conflicts and improve maintainability.

To verify the impact of this change, you can run the following script:

This script will help ensure that the version update has been applied consistently and provide an overview of all CSS versions in use.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other occurrences of the old CSS version and list all unique CSS versions used.

# Test 1: Check for any other occurrences of the old CSS version
echo "Checking for other occurrences of the old CSS version:"
rg --type html "1\.0\.72-campaign" health/micro-ui/web/micro-ui-internals/

# Test 2: List all unique CSS versions used
echo -e "\nListing all unique CSS versions used:"
rg --type html -o '@egovernments/digit-ui-css@[0-9.a-z-]+' health/micro-ui/web/micro-ui-internals/ | sort -u

Length of output: 925

Comment on lines +15 to +33
<div className="subBoundarycomp-container">
{arr.map((el, ind) => {
return (
<div key={ind} className="digit-tag-container" style={{ minWidth: "1rem" }} >
<Chip
className=""
error=""
extraStyles={{
color: 'red',
display: "inline-block", // Ensures Chip behaves inline within its container
}}
onClick={() => { }}
onTagClick={() => { }}
text={el} // Text from arr
/>
</div>
);
})}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider implementing click handlers and moving styles to CSS.

The Chip components have empty click handlers, which might indicate incomplete functionality. Additionally, inline styles could be moved to a separate CSS file for better maintainability.

  1. Implement the click handlers or remove them if not needed:
-   onClick={() => { }}
-   onTagClick={() => { }}
+   // onClick={handleChipClick}
+   // onTagClick={handleTagClick}
  1. Consider moving inline styles to a CSS file:
- style={{ minWidth: "1rem" }}
+ className="chip-container"

Then in your CSS file:

.chip-container {
  min-width: 1rem;
}

Comment on lines +6 to +7
const SubBoundaryView = ({ title, arr }) => {
console.log("subBoundaryView",title,arr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Remove console.log statement before production deployment.

While console.log statements are useful for debugging, they should be removed before deploying to production.

Consider removing or commenting out the following line:

-    console.log("subBoundaryView",title,arr);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const SubBoundaryView = ({ title, arr }) => {
console.log("subBoundaryView",title,arr);
const SubBoundaryView = ({ title, arr }) => {
// console.log("subBoundaryView",title,arr);

Comment on lines +1 to +4
import React from 'react'
import HeaderComp from './HeaderComp';
import { Card } from '@egovernments/digit-ui-components';
import { Chip } from '@egovernments/digit-ui-components';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider combining imports from the same library.

The imports from @egovernments/digit-ui-components can be combined for better readability and maintainability.

Consider updating the imports as follows:

import React from 'react'
import HeaderComp from './HeaderComp';
-import { Card } from '@egovernments/digit-ui-components';
-import { Chip } from '@egovernments/digit-ui-components';
+import { Card, Chip } from '@egovernments/digit-ui-components';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import React from 'react'
import HeaderComp from './HeaderComp';
import { Card } from '@egovernments/digit-ui-components';
import { Chip } from '@egovernments/digit-ui-components';
import React from 'react'
import HeaderComp from './HeaderComp';
import { Card, Chip } from '@egovernments/digit-ui-components';

@@ -27,6 +28,7 @@ const InboxSearchLinks = ({headerText, links, businessService, customClass="", l
<div className={`inbox-search-links-container ${customClass}`}>
{renderHeader()}
<div className="contents">
{console.log(linksToshow, "hehe")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove console.log and fix variable name typo.

This line contains two issues:

  1. A console.log statement that should not be in production code.
  2. A typo in the variable name ('linksToshow' instead of 'linksToShow').

Apply this diff to remove the console.log and fix the typo:

-                {console.log(linksToshow, "hehe")}

If logging is necessary for debugging, replace it with a proper logging mechanism and fix the variable name:

-                {console.log(linksToshow, "hehe")}
+                {Digit.Utils.log("Links to show in InboxSearchLinks", linksToShow)}

Ensure to use an appropriate logging utility that can be configured based on the environment.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{console.log(linksToshow, "hehe")}

Comment on lines 729 to 793
Array.isArray(bHierarchy) && bHierarchy.length > 1 && bHierarchy.filter((_, index) => ![0, bHierarchy.length - 1].includes(index)).map((item, ind) => {
//item-Country,Province,Locality,District,Village
console.log("item", item);
if (parent_group[item] && Array.isArray(parent_group[item])) {
return parent_group[item].map((item1, idx) => {
//item1-Province-[Sinoe],District-[Jedepo,Jeade]
console.log("item1", item1);
return Array.isArray(item1) && (!boundaryStatus[ind]) ? ( //changed
//make a super-comp that contains SubBoundary View
<Card key={`card_${ind}_${idx}`}>
<HeaderComp title={bHierarchy[ind + 2]} />
{item1.map((item2) => {
//item2-parents name eg, sino etc
console.log("item2", item2);
return (
<SubBoundaryView
key={`${item2}_${idx}`}
title={item2}
arr={parents[item2]}
/>);
})
}
<div
onClick={() => handleViewMore(ind)}
className="view-more"
>
View Less
</div>
</Card>
) : (Array.isArray(item1) && (boundaryStatus[ind])) ? (
<div key={`div_${ind}_${idx}`}>
<Card>
<HeaderComp title={bHierarchy[ind + 2]} />
{item1.filter((_, idexer) => (idexer == 0 || idexer == 1)).map((item2) => (
//item2-parents name eg, sino etc
<SubBoundaryView
key={`${item2}_${idx}`}
title={item2}
arr={parents[item2]}
/>
))
}
<div
onClick={() => handleViewMore(ind)}
className="view-more"
>
View More
</div>
</Card>




</div>



) : (null)



});
}
return null;
})}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor complex and deeply nested rendering logic

The rendering logic starting at line 729 is deeply nested and uses complex conditional statements, which can make the code difficult to read and maintain. Consider refactoring this section by extracting parts into separate components or helper functions to simplify the JSX structure.

🧰 Tools
🪛 Biome

[error] 751-754: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)


[error] 771-774: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)

// Set showAllItems to true to show all items
};

const selectedData1 = customProps?.sessionData?.BOUNDARY?.boundarySelection?.selectedData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Remove unused variable selectedData1

The variable selectedData1 is declared but never used in the code. Unused variables can lead to confusion and should be removed to keep the code clean.

Apply this diff:

- const selectedData1 = customProps?.sessionData?.BOUNDARY?.boundarySelection?.selectedData;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const selectedData1 = customProps?.sessionData?.BOUNDARY?.boundarySelection?.selectedData;

Comment on lines 726 to 728
{console.log("bHierarchy", bHierarchy)};

{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unnecessary semicolon in JSX

There is an unnecessary semicolon after the JSX expression, which can cause a syntax error.

Apply this diff:

- {console.log("bHierarchy", bHierarchy)};
+ {console.log("bHierarchy", bHierarchy)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{console.log("bHierarchy", bHierarchy)};
{
{console.log("bHierarchy", bHierarchy)}
{
🧰 Tools
🪛 Biome

[error] 726-728: There is a suspicious semicolon in the JSX element.

This is usually the result of a typo or some refactor gone wrong.
Remove the semicolon, or move it inside a JSX element.

(lint/suspicious/noSuspiciousSemicolonInJsx)

Comment on lines +656 to +660
useEffect(() => {
if (selectedData && selectedData.length >= 0) {
setStatusMap(() => Digit.Utils.microplanv1.createStatusMap(selectedData, boundaryHierarchy))
}
}, [boundaryHierarchy])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add selectedData to the useEffect dependency array

The useEffect hook uses selectedData but does not include it in the dependency array. This may lead to stale values or unexpected behavior when selectedData changes.

Apply this diff:

}, [boundaryHierarchy, selectedData])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
if (selectedData && selectedData.length >= 0) {
setStatusMap(() => Digit.Utils.microplanv1.createStatusMap(selectedData, boundaryHierarchy))
}
}, [boundaryHierarchy])
useEffect(() => {
if (selectedData && selectedData.length >= 0) {
setStatusMap(() => Digit.Utils.microplanv1.createStatusMap(selectedData, boundaryHierarchy))
}
}, [boundaryHierarchy, selectedData])

Comment on lines +14 to +27
const handleViewMore = (ind) => {
// Create a copy of the boundaryStatus array
const updatedBoundaryStatus = [...boundaryStatus];
// Update the ind + 1 position to false
if (boundaryStatus[ind]) {
updatedBoundaryStatus[ind] = false;
} else {
updatedBoundaryStatus[ind] = true;

}
// Set the updated array in the state
setBoundaryStatus(updatedBoundaryStatus);
// Set showAllItems to true to show all items
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Simplify the toggle logic in handleViewMore

The handleViewMore function can be simplified by directly toggling the boolean value, improving code clarity.

Apply this diff:

const handleViewMore = (ind) => {
    const updatedBoundaryStatus = [...boundaryStatus];
-   if (boundaryStatus[ind]) {
-       updatedBoundaryStatus[ind] = false;
-   } else {
-       updatedBoundaryStatus[ind] = true;
-   }
+   updatedBoundaryStatus[ind] = !boundaryStatus[ind];
    setBoundaryStatus(updatedBoundaryStatus);
};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleViewMore = (ind) => {
// Create a copy of the boundaryStatus array
const updatedBoundaryStatus = [...boundaryStatus];
// Update the ind + 1 position to false
if (boundaryStatus[ind]) {
updatedBoundaryStatus[ind] = false;
} else {
updatedBoundaryStatus[ind] = true;
}
// Set the updated array in the state
setBoundaryStatus(updatedBoundaryStatus);
// Set showAllItems to true to show all items
};
const handleViewMore = (ind) => {
// Create a copy of the boundaryStatus array
const updatedBoundaryStatus = [...boundaryStatus];
// Update the ind position by toggling its value
updatedBoundaryStatus[ind] = !boundaryStatus[ind];
// Set the updated array in the state
setBoundaryStatus(updatedBoundaryStatus);
// Set showAllItems to true to show all items
};

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between d928ebf and 90f02b5.

📒 Files selected for processing (3)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignBoundary.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/HeaderPlusThreeInput.js (0 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/ThreeInputComp.js (0 hunks)
💤 Files with no reviewable changes (2)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/HeaderPlusThreeInput.js
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/ThreeInputComp.js
🧰 Additional context used
📓 Path-based instructions (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignBoundary.js (1)

Pattern **/*.js: check

🪛 Biome
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/CampaignBoundary.js

[error] 763-766: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)


[error] 788-791: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)


[error] 606-606: This let declares a variable that is only assigned once.

'parents' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 607-607: This let declares a variable that is only assigned once.

'parent_group' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 679-679: This let declares a variable that is only assigned once.

'bH' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 681-681: This let declares a variable that is only assigned once.

'dic' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 684-684: This let declares a variable that is only assigned once.

'bType' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 685-685: This let declares a variable that is only assigned once.

'parent' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

Comment on lines +684 to +685
let bType = ob["boundaryType"];
let parent = ob["parentBoundaryType"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use const instead of let for variables that are not reassigned

The variables bType and parent are declared with let but are never reassigned. Using const prevents accidental reassignments and improves code readability.

Apply this diff:

-            let bType = ob["boundaryType"];
-            let parent = ob["parentBoundaryType"];
+            const bType = ob["boundaryType"];
+            const parent = ob["parentBoundaryType"];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let bType = ob["boundaryType"];
let parent = ob["parentBoundaryType"];
const bType = ob["boundaryType"];
const parent = ob["parentBoundaryType"];
🧰 Tools
🪛 Biome

[error] 684-684: This let declares a variable that is only assigned once.

'bType' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 685-685: This let declares a variable that is only assigned once.

'parent' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

Comment on lines +679 to +681
let bH = [];
let top = null;
let dic = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use const instead of let for variables that are not reassigned

The variables bH and dic are declared with let but are never reassigned. Using const prevents accidental reassignments and improves code readability.

Apply this diff:

-            let bH = [];
-            let dic = {};
+            const bH = [];
+            const dic = {};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let bH = [];
let top = null;
let dic = {};
const bH = [];
let top = null;
const dic = {};
🧰 Tools
🪛 Biome

[error] 679-679: This let declares a variable that is only assigned once.

'bH' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 681-681: This let declares a variable that is only assigned once.

'dic' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

Comment on lines +788 to +791
<div
onClick={() => handleViewMore(ind)}
className="view-more"
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add keyboard accessibility to clickable div elements

The div element with an onClick handler should also handle keyboard events and have appropriate roles to be accessible to keyboard-only users.

Apply this diff:

 <div
     onClick={() => handleViewMore(ind)}
+    onKeyPress={(e) => { if (e.key === 'Enter') handleViewMore(ind); }}
+    role="button"
+    tabIndex="0"
     className="view-more"
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
onClick={() => handleViewMore(ind)}
className="view-more"
>
<div
onClick={() => handleViewMore(ind)}
onKeyPress={(e) => { if (e.key === 'Enter') handleViewMore(ind); }}
role="button"
tabIndex="0"
className="view-more"
>
🧰 Tools
🪛 Biome

[error] 788-791: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)

Comment on lines +763 to +766
<div
onClick={() => handleViewMore(ind)}
className="view-more"
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add keyboard accessibility to clickable div elements

The div element with an onClick handler should also handle keyboard events and have appropriate roles to be accessible to keyboard-only users.

Apply this diff:

 <div
     onClick={() => handleViewMore(ind)}
+    onKeyPress={(e) => { if (e.key === 'Enter') handleViewMore(ind); }}
+    role="button"
+    tabIndex="0"
     className="view-more"
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
onClick={() => handleViewMore(ind)}
className="view-more"
>
<div
onClick={() => handleViewMore(ind)}
onKeyPress={(e) => { if (e.key === 'Enter') handleViewMore(ind); }}
role="button"
tabIndex="0"
className="view-more"
>
🧰 Tools
🪛 Biome

[error] 763-766: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant