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

Facility catchment Popup for unassign #1818

Open
wants to merge 6 commits into
base: console
Choose a base branch
from
Open

Conversation

abishekTa-egov
Copy link

@abishekTa-egov abishekTa-egov commented Nov 13, 2024

Facility catchment Popup for unassign

Summary by CodeRabbit

  • New Features

    • Introduced a confirmation popup for unassigning facilities to enhance user interaction.
    • Improved accessibility and user experience with updated cell rendering in the facility table.
  • Bug Fixes

    • Enhanced logic for handling unassignment actions to ensure proper confirmation flow.

@abishekTa-egov abishekTa-egov requested a review from a team as a code owner November 13, 2024 10:25
Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in FacilityPopup.js introduce a new state variable to manage the visibility of a confirmation popup for unassigning facilities. Two asynchronous functions are added to handle the confirmation logic, and the existing handleAssignUnassign function is modified to trigger the confirmation dialog. Additionally, the columns array is updated to enhance accessibility and interactivity in the table cells. A new PopUp component is conditionally rendered based on the state variable, allowing users to confirm or cancel the unassignment action.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js - Added state variable confirmUnasignPopup for confirmation dialog visibility.
- Introduced methods handleUnsaasignFalse and handleUnsaasignTrue for handling popup actions.
- Modified handleAssignUnassign to trigger the confirmation dialog.
- Updated columns array to include cell property for accessibility and interactivity.

Possibly related PRs

  • Changes regarding facility catchment popup #1741: Changes regarding facility catchment popup - This PR modifies the FacilityPopUp component, which is directly related to the changes made in the main PR for FacilityPopup.js, particularly in how the component handles props and updates details.
  • Facility mapper #1590: Facility mapper - This PR includes significant updates to the FacilityPopup component, enhancing its functionality and state management, which aligns with the changes made in the main PR regarding state variables and handling user interactions.

Suggested reviewers

  • nabeelmd-eGov
  • nipunarora-eGov

Poem

🐇 In the popup, a choice to make,
Unassigning with a little shake.
Click to confirm, or just say no,
A friendly dialog to help you know!
With columns wrapped in a cozy nest,
User interactions are surely blessed! 🌟


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

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

Line range hint 284-331: Refactor handler functions for better maintainability

Issues found:

  1. Typo in function names ("Unsaasign" vs "Unassign")
  2. Use of var instead of const
  3. handleAssignUnassign only handles unassign case despite the name suggesting both operations
- const handleUnsaasignTrue = async () => {
+ const handleUnassignConfirm = async () => {
    setLoader(true);
-   var newDetails = JSON.parse(JSON.stringify(details));
+   const newDetails = JSON.parse(JSON.stringify(details));
    // ... rest of the code
  }

- const handleAssignUnassign = async () => {
+ const handleFacilityAction = async () => {
    setLoader(true);
-   var newDetails = JSON.parse(JSON.stringify(details));
+   const newDetails = JSON.parse(JSON.stringify(details));
    if (facilityAssignedStatus) {
      setConfirmUnasignPopup(true);
      // ... unassign logic
+   } else {
+     // ... assign logic should be here
    }
    setLoader(false);
  };

Also applies to: 333-348

🧰 Tools
🪛 Biome

[error] 288-288: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 0539c64 and 590be39.

📒 Files selected for processing (1)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (1)

Pattern **/*.js: check

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

[error] 288-288: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


[error] 337-337: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


[error] 510-540: 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] 515-515: Avoid passing children using a prop

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

(lint/correctness/noChildrenProp)


[error] 516-516: 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] 524-533: 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] 534-534: 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)

@@ -30,6 +30,7 @@ const FacilityPopUp = ({ details, onClose, updateDetails }) => {
const [currentPage, setCurrentPage] = useState(1);
const [rowsPerPage, setRowsPerPage] = useState(10);
const [boundaryData, setBoundaryData] = useState([]);
const [confirmUnasignPopup,setConfirmUnasignPopup]=useState(false);
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 13, 2024

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix state variable naming convention and typo

The state variable name should follow React naming conventions and correct spelling:

  • Use camelCase
  • Fix typo in "Unasign"
- const [confirmUnasignPopup,setConfirmUnasignPopup]=useState(false);
+ const [confirmUnassignPopup, setConfirmUnassignPopup] = useState(false);
📝 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 [confirmUnasignPopup,setConfirmUnasignPopup]=useState(false);
const [confirmUnassignPopup, setConfirmUnassignPopup] = useState(false);

Copy link
Contributor

Choose a reason for hiding this comment

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

@abishekTa-egov check for typos, if it is less time consuming.. can u fix the typos

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 13, 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: 2

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

Line range hint 284-331: Fix naming convention and use const

The function has a typo in its name and uses var instead of const.

-const handleUnsaasignTrue = async () => {
+const handleUnassignConfirm = async () => {
   setLoader(true);
-  var newDetails = JSON.parse(JSON.stringify(details));
+  const newDetails = JSON.parse(JSON.stringify(details));
🧰 Tools
🪛 Biome

[error] 288-288: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 590be39 and 885f1a4.

📒 Files selected for processing (1)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (1)

Pattern **/*.js: check

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

[error] 288-288: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


[error] 337-337: Use let or const instead of var.

A variable declared with var is accessible in the whole body of the function. Thus, the variable can be accessed before its initialization and outside the block where it is declared.
See MDN web docs for more details.
Unsafe fix: Use 'const' instead.

(lint/style/noVar)


[error] 538-568: 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] 543-543: Avoid passing children using a prop

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

(lint/correctness/noChildrenProp)


[error] 544-544: 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] 552-561: 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] 562-562: 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)

🔇 Additional comments (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (3)

217-262: LGTM: Table columns implementation

The table columns implementation with accessibility improvements looks good. The cells are properly structured with title attributes and cursor styling for better user interaction.


278-282: 🛠️ Refactor suggestion

Remove unnecessary function and return statement

The handleUnsaasignFalse function can be simplified to an inline handler.

-const handleUnsaasignFalse = async () => {
-  setConfirmUnasignPopup(false);
-  return
-}

Update the button onClick to:

-onClick={handleUnsaasignFalse}
+onClick={() => setConfirmUnassignPopup(false)}

Likely invalid or redundant comment.


33-33: ⚠️ Potential issue

Fix state variable naming convention and typo

The state variable has a typo in "Unasign" and should follow React naming conventions.

-const [confirmUnasignPopup,setConfirmUnasignPopup]=useState(false);
+const [confirmUnassignPopup, setConfirmUnassignPopup] = useState(false);

Likely invalid or redundant comment.

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