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

added facility search #1556

Merged
merged 3 commits into from
Oct 18, 2024
Merged

added facility search #1556

merged 3 commits into from
Oct 18, 2024

Conversation

Swathi-eGov
Copy link
Contributor

@Swathi-eGov Swathi-eGov commented Oct 18, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new FacilityPopup component for enhanced user interactions with facility-related information.
    • Added a FacilityCatchmentMapping component to facilitate the assignment of catchment villages.
    • New CSS class .facility-popup improves the styling of popup elements.
  • Enhancements

    • Improved stylesheet modularity by importing additional styles related to facilities.
    • Enhanced routing capabilities with a new private route for assigning facilities to villages.
  • Configuration Updates

    • Added a configuration module for facility mapping, defining the structure and behavior of the search interface for facilities.
    • Introduced new customization options for facility-related UI components.

Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes introduce several new components and configurations related to facility management within the micro UI framework. A new CSS class for popups has been added, alongside a new React component, FacilityPopUp, and a configuration module for facility mapping. Additional modifications include updates to existing components and routing capabilities, enhancing the modularity and functionality of the application.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss Added new CSS class .facility-popup for styling popup elements.
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss Added import statement for facility.scss to enhance stylesheet modularity.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/Module.js Imported FacilityPopup and added it to componentsToRegister; minor formatting change for FormulaConfigScreen.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js Introduced new React component FacilityPopUp with props for details and onClose functionality.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/FacilityMappingConfig.js Added facilityMappingConfig function for facility mapping configuration.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js Modified UICustomizations to include FacilityMappingConfig with new methods.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMapping.js Introduced new React component FacilityCatchmentMapping for assigning catchment villages.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js Added import for FacilityCatchmentMapping, updated useCustomMDMS, and introduced new PrivateRoute.

Possibly related PRs

  • Side component #1410: This PR introduces a new CSS class .homeWrapper, which may relate to layout adjustments similar to the .facility-popup class added in the main PR.
  • CSS Issue fix, locaisation/mdms cache issue fix  #1418: This PR includes modifications to existing CSS classes, which may have overlapping styling concerns with the new .facility-popup class.
  • bug fixes for sandbox #1439: This PR involves updates to the CSS in the sandbox environment, which could relate to the styling changes introduced in the main PR.
  • Sandbox UI fixes #1442: This PR focuses on UI fixes in the sandbox, which may include adjustments relevant to the new styles introduced in the main PR.
  • side bar faq-component changes #1534: This PR introduces a new class .faq-answer and modifies existing classes in sandbox.scss, which may relate to the overall styling context of the changes in the main PR.

Suggested reviewers

  • nipunarora-eGov

🐰 "In the meadow where popups bloom,
A new class brings style to the room.
With components fresh and routes anew,
We hop along, with joy in view!
For facilities, we make a way,
In our UI, bright as day!" 🐇


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: 25

🧹 Outside diff range comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/Module.js (1)

Inconsistent Naming of FacilityPopup Component

  • The FacilityPopup component is imported in Module.js correctly.
  • In UICustomizations.js, it is imported as FacilityPopUp, which has inconsistent casing.
  • Ensure consistent naming (FacilityPopup) across all imports to prevent potential import errors and maintain code reliability.
🔗 Analysis chain

Line range hint 52-77: Consider alphabetical sorting and verify FacilityPopup usage.

While the changes look good, here are two suggestions for improvement:

  1. Consider sorting the componentsToRegister object alphabetically for easier maintenance and readability.

  2. Ensure that the FacilityPopup component is correctly used in other parts of the application where needed.

To verify the usage of FacilityPopup in the codebase, you can run the following script:

This script will help identify where FacilityPopup is being used and imported throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for FacilityPopup usage in the codebase

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

# Test: Check if FacilityPopup is imported in other files
echo "Checking for FacilityPopup imports:"
rg --type js 'import.*FacilityPopup'

Length of output: 905

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between ae8c2d7 and 679eada.

📒 Files selected for processing (8)
  • health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.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/FacilityPopup.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/FacilityMappingConfig.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (8 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMappnig.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
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/FacilityPopup.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

[error] 20-22: 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)


[error] 19-19: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)


[error] 20-22: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 26-33: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

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

[error] 6-6: Unexpected empty object pattern.

(lint/correctness/noEmptyPattern)


[error] 14-16: 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 (8)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMappnig.js (1)

13-13: Verify the existence of the "inbox-search-wrapper" class.

The component uses the className "inbox-search-wrapper", but its styling is not visible in this file. Ensure that this class is defined in your CSS files or styled-components to avoid potential styling issues.

Run the following script to check for the usage of this class name:

✅ Verification successful

Verified: The "inbox-search-wrapper" class is properly defined in the CSS files and is used correctly within the components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for the usage and definition of the "inbox-search-wrapper" class

# Test: Search for the class name in CSS files
echo "Searching for 'inbox-search-wrapper' in CSS files:"
rg --type css 'inbox-search-wrapper'

# Test: Search for the class name in JS/JSX files (for styled-components)
echo "Searching for 'inbox-search-wrapper' in JS/JSX files:"
rg --type js 'inbox-search-wrapper'

Length of output: 3694

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

9-11: LGTM: Component setup and configuration.

The translation setup and configuration retrieval look good. The use of useTranslation hook and facilityMappingConfig is appropriate for the component's needs.


41-41: LGTM: Component export.

The default export of the FacilityPopUp component is correct and follows common React practices.

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

24-24: LGTM: FacilityPopup import added correctly.

The import statement for the new FacilityPopup component is correctly implemented.

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

69-71: LGTM: Additional MDMS data requests

The addition of "facilityType" and "facilityStatus" to the MDMS data requests is appropriate for implementing the facility search functionality. This change will ensure that the necessary data for facility types and statuses is available in the application.


Line range hint 1-195: Summary of changes

The changes in this file successfully introduce new functionality for facility search and assignment, aligning with the PR objective. The additions include:

  1. A new import for the FacilityCatchmentMapping component (with a typo to be fixed).
  2. Additional MDMS data requests for facility types and statuses.
  3. A new PrivateRoute for the facility assignment functionality.

These changes enhance the application's capabilities for facility management within the microplanning context. Please address the typo in the import statement, and the changes look good to merge after verification.

🧰 Tools
🪛 Biome

[error] 74-74: Use Number.Infinity instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.Infinity instead.

(lint/style/useNumberNamespace)

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

50-50: Review the regular expression patterns for accuracy

The regex patterns used in the validation for facilityName and residingVillage are complex and may be overly restrictive. Consider reviewing and testing these patterns to ensure they correctly validate user input without unintended exclusions.

Also applies to: 95-95


66-66: Ensure 'state' properties are correctly populated

In the options for facilityType and status, you're using state?.facilityType || [] and state?.facilityStatus || []. Verify that state.facilityType and state.facilityStatus are correctly populated to prevent potential issues if these properties are undefined or null.

Run the following script to check where state.facilityType and state.facilityStatus are assigned:

Also applies to: 80-80

coderabbitai[bot]
coderabbitai bot previously requested changes Oct 18, 2024
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: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 679eada and 8335f9c.

📒 Files selected for processing (4)
  • 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/FacilityPopup.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMapping.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/index.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
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/FacilityPopup.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

[error] 18-20: 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)


[error] 17-17: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)


[error] 18-20: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 24-31: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

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

[error] 14-16: 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 (8)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/FacilityCatchmentMapping.js (3)

1-4: LGTM: Imports are well-organized and appropriate.

The imports are correctly structured, importing necessary components and hooks. The use of a separate configuration file (facilityMappingConfig) promotes modularity and maintainability.


6-9: LGTM: Component structure follows best practices.

The FacilityCatchmentMapping component is well-structured as a functional component. It correctly uses the useTranslation hook for internationalization and retrieves configuration data, promoting maintainability and separation of concerns.


10-19: LGTM: Rendering logic is clear and well-structured.

The component's rendering logic is straightforward and effective. It correctly uses the Header component with a translated string and the InboxSearchComposer with the retrieved configuration. The use of a React Fragment is appropriate for wrapping multiple elements without adding extra nodes to the DOM.

🧰 Tools
🪛 Biome

[error] 14-16: 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)

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

1-39: Overall assessment: Good implementation with minor improvements needed.

The FacilityPopUp component introduces a new feature for facility mapping, which aligns well with the PR objectives. The overall structure and functionality of the component are appropriate for its purpose.

Key points:

  1. The component correctly utilizes React hooks and external libraries.
  2. The popup structure with a search composer and close button is logically implemented.
  3. Minor issues were identified and addressed in the previous comments, including unused imports, JSX structure improvements, and proper use of key props.

To further improve the component:

  1. Implement the suggested changes for JSX structure and prop usage.
  2. Remove the unused Card import.
  3. Consider adding prop-types for better type checking and documentation.
  4. Evaluate if any unit tests should be added to ensure the component's functionality.
🧰 Tools
🪛 Biome

[error] 18-20: 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)


[error] 17-17: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)


[error] 18-20: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 24-31: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

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

24-24: LGTM: FacilityPopup import added correctly.

The import statement for the new FacilityPopup component is correctly added and follows the existing import style in the file.

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

190-190: Existing concern: Missing FacilityCatchmentMapping component

The previous review comment regarding the missing FacilityCatchmentMapping component is still applicable to this code segment.


19-19: Verify the existence of FacilityCatchmentMapping component

Ensure that the FacilityCatchmentMapping component exists at the specified path "./FacilityCatchmentMapping". This will prevent runtime errors due to missing modules.

To confirm, run the following script:

✅ Verification successful

Verification Successful: FacilityCatchmentMapping component exists

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if FacilityCatchmentMapping.js exists in the specified directory.

fd --type f "FacilityCatchmentMapping.js" --exec echo "Found: {}"

Length of output: 187


70-71: Verify MDMS entries for facilityType and facilityStatus

Ensure that the MDMS configurations for "facilityType" and "facilityStatus" exist and are properly defined in the hcm-microplanning module to prevent runtime errors when accessing this data.

To confirm, run the following script:

Comment on lines +14 to +17
<InboxSearchComposer
configs={config}
></InboxSearchComposer>
</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)

Use self-closing tag for InboxSearchComposer.

The InboxSearchComposer component is rendered without children, so it should use a self-closing tag for better readability and to follow JSX best practices.

Please update the code as follows:

-            <InboxSearchComposer
-              configs={config}
-            ></InboxSearchComposer>
+            <InboxSearchComposer
+              configs={config}
+            />
📝 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
<InboxSearchComposer
configs={config}
></InboxSearchComposer>
</div>
<InboxSearchComposer
configs={config}
/>
</div>
🧰 Tools
🪛 Biome

[error] 14-16: 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)

Comment on lines +1 to +5
import React, { useState, useMemo, Fragment, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { PopUp, Button, Card } from "@egovernments/digit-ui-components";
import { InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import facilityMappingConfig from "../configs/FacilityMappingConfig";
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 reorganizing imports for better readability.

The imports are relevant and there are no unused imports. However, consider organizing them in the following order for better readability:

  1. React and related libraries
  2. External libraries (e.g., react-i18next)
  3. Internal components and utilities

Here's a suggested reorganization:

import React, { useState, useMemo, Fragment, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { PopUp, Button, Card } from "@egovernments/digit-ui-components";
import { InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import facilityMappingConfig from "../configs/FacilityMappingConfig";

import { InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import facilityMappingConfig from "../configs/FacilityMappingConfig";

const FacilityPopUp = ({ details, onClose }) => {
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 adding prop-types for better type checking.

To improve the component's robustness and documentation, consider adding prop-types. This will help catch potential issues early and provide better documentation for the component's API.

Example:

import PropTypes from 'prop-types';

// ... component code ...

FacilityPopUp.propTypes = {
  details: PropTypes.shape({
    additionalDetails: PropTypes.shape({
      name: PropTypes.string
    })
  }),
  onClose: PropTypes.func.isRequired
};

Would you like assistance in implementing prop-types for this component?

Comment on lines +7 to +37
const FacilityPopUp = ({ details, onClose }) => {
const { t } = useTranslation();

const config = facilityMappingConfig();

return (
<>
<PopUp
onClose={onClose}
heading={`${t(`MICROPLAN_ASSIGNMENT_FACILITY`)} ${details?.additionalDetails?.name}`}
children={[
<InboxSearchComposer
configs={config} // dummy config
></InboxSearchComposer>,
]}
onOverlayClick={onClose}
footerChildren={[
<Button
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t(`MICROPLAN_CLOSE_BUTTON`)}
onClick={onClose}
/>,
]}
className={"facility-popup"}
/>
</>
);
};
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

Improve JSX structure and prop usage.

There are several improvements that can be made to the JSX structure:

  1. Use self-closing tags for elements without children.
  2. Avoid passing children as a prop to PopUp.
  3. Add key props to elements in iterables.

Apply these changes to address the issues:

 <PopUp
   onClose={onClose}
   heading={`${t(`MICROPLAN_ASSIGNMENT_FACILITY`)} ${details?.additionalDetails?.name}`}
-  children={[
-    <InboxSearchComposer
-      configs={config} // dummy config
-    ></InboxSearchComposer>,
-  ]}
+  >
+    <InboxSearchComposer
+      configs={config} // dummy config
+    />
   onOverlayClick={onClose}
   footerChildren={[
     <Button
+      key="close-button"
       className={"campaign-type-alert-button"}
       type={"button"}
       size={"large"}
       variation={"secondary"}
       label={t(`MICROPLAN_CLOSE_BUTTON`)}
       onClick={onClose}
-    />,
+    />
   ]}
   className={"facility-popup"}
 />

These changes will improve the component's structure and address the static analysis warnings.

📝 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 FacilityPopUp = ({ details, onClose }) => {
const { t } = useTranslation();
const config = facilityMappingConfig();
return (
<>
<PopUp
onClose={onClose}
heading={`${t(`MICROPLAN_ASSIGNMENT_FACILITY`)} ${details?.additionalDetails?.name}`}
children={[
<InboxSearchComposer
configs={config} // dummy config
></InboxSearchComposer>,
]}
onOverlayClick={onClose}
footerChildren={[
<Button
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t(`MICROPLAN_CLOSE_BUTTON`)}
onClick={onClose}
/>,
]}
className={"facility-popup"}
/>
</>
);
};
const FacilityPopUp = ({ details, onClose }) => {
const { t } = useTranslation();
const config = facilityMappingConfig();
return (
<>
<PopUp
onClose={onClose}
heading={`${t(`MICROPLAN_ASSIGNMENT_FACILITY`)} ${details?.additionalDetails?.name}`}
>
<InboxSearchComposer
configs={config} // dummy config
/>
onOverlayClick={onClose}
footerChildren={[
<Button
key="close-button"
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t(`MICROPLAN_CLOSE_BUTTON`)}
onClick={onClose}
/>
]}
className={"facility-popup"}
/>
</>
);
};
🧰 Tools
🪛 Biome

[error] 18-20: 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)


[error] 17-17: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)


[error] 18-20: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 24-31: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

Comment on lines +1 to +39
import React, { useState, useMemo, Fragment, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { PopUp, Button, Card } from "@egovernments/digit-ui-components";
import { InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import facilityMappingConfig from "../configs/FacilityMappingConfig";

const FacilityPopUp = ({ details, onClose }) => {
const { t } = useTranslation();

const config = facilityMappingConfig();

return (
<>
<PopUp
onClose={onClose}
heading={`${t(`MICROPLAN_ASSIGNMENT_FACILITY`)} ${details?.additionalDetails?.name}`}
children={[
<InboxSearchComposer
configs={config} // dummy config
></InboxSearchComposer>,
]}
onOverlayClick={onClose}
footerChildren={[
<Button
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t(`MICROPLAN_CLOSE_BUTTON`)}
onClick={onClose}
/>,
]}
className={"facility-popup"}
/>
</>
);
};

export default FacilityPopUp;
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 unused Card import.

The Card component is imported but not used in the component. Remove the unused import to keep the code clean:

- import { PopUp, Button, Card } from "@egovernments/digit-ui-components";
+ import { PopUp, Button } 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, { useState, useMemo, Fragment, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { PopUp, Button, Card } from "@egovernments/digit-ui-components";
import { InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import facilityMappingConfig from "../configs/FacilityMappingConfig";
const FacilityPopUp = ({ details, onClose }) => {
const { t } = useTranslation();
const config = facilityMappingConfig();
return (
<>
<PopUp
onClose={onClose}
heading={`${t(`MICROPLAN_ASSIGNMENT_FACILITY`)} ${details?.additionalDetails?.name}`}
children={[
<InboxSearchComposer
configs={config} // dummy config
></InboxSearchComposer>,
]}
onOverlayClick={onClose}
footerChildren={[
<Button
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t(`MICROPLAN_CLOSE_BUTTON`)}
onClick={onClose}
/>,
]}
className={"facility-popup"}
/>
</>
);
};
export default FacilityPopUp;
import React, { useState, useMemo, Fragment, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { PopUp, Button } from "@egovernments/digit-ui-components";
import { InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import facilityMappingConfig from "../configs/FacilityMappingConfig";
const FacilityPopUp = ({ details, onClose }) => {
const { t } = useTranslation();
const config = facilityMappingConfig();
return (
<>
<PopUp
onClose={onClose}
heading={`${t(`MICROPLAN_ASSIGNMENT_FACILITY`)} ${details?.additionalDetails?.name}`}
children={[
<InboxSearchComposer
configs={config} // dummy config
></InboxSearchComposer>,
]}
onOverlayClick={onClose}
footerChildren={[
<Button
className={"campaign-type-alert-button"}
type={"button"}
size={"large"}
variation={"secondary"}
label={t(`MICROPLAN_CLOSE_BUTTON`)}
onClick={onClose}
/>,
]}
className={"facility-popup"}
/>
</>
);
};
export default FacilityPopUp;
🧰 Tools
🪛 Biome

[error] 18-20: 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)


[error] 17-17: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)


[error] 18-20: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 24-31: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

Comment on lines +76 to +77
FormulaConfigScreen,
FacilityPopup,
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)

LGTM: FacilityPopup registered correctly. Minor suggestion for consistency.

The FacilityPopup component is correctly added to the componentsToRegister object. The trailing comma after FormulaConfigScreen is a good practice.

For consistency, consider adding a trailing comma after FacilityPopup as well:

 FormulaConfigScreen,
-FacilityPopup
+FacilityPopup,

This will maintain consistency and make future additions easier.

📝 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
FormulaConfigScreen,
FacilityPopup,
FormulaConfigScreen,
FacilityPopup,

@nipunarora-eGov nipunarora-eGov merged commit 1cf36f8 into console Oct 18, 2024
3 checks passed
@nipunarora-eGov nipunarora-eGov deleted the Facility-Serach branch October 18, 2024 06:45
@coderabbitai coderabbitai bot mentioned this pull request Oct 28, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 13, 2024
@nabeelmd-eGov nabeelmd-eGov mentioned this pull request Dec 10, 2024
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.

2 participants