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

FEATURE/HCMPRE-1709: Accessibility Dropdown #2087

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

Conversation

abishekTa-egov
Copy link
Contributor

@abishekTa-egov abishekTa-egov commented Dec 30, 2024

FEATURE/HCMPRE-1709: For Single Select Dropdowns(Village road condition, Village terrain, Civil unrest occurrence, Security forces patrolling) + integrate with MDMS to show list of accessibility details

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced filtering capabilities for the microplan inbox with new filter criteria.
    • Added new dropdown layout with improved spacing.
  • Styling

    • Updated CSS stylesheet to version 0.2.33.
    • Added .gap-between-dropdowns class for better dropdown layout.
  • Bug Fixes

    • Improved filter management in the microplan inbox.
    • Updated state management for more granular filter control.

@abishekTa-egov abishekTa-egov requested a review from a team as a code owner December 30, 2024 09:43
Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

📝 Walkthrough

Walkthrough

This pull request introduces updates to the health module's UI components, focusing on enhancing filter functionality and updating stylesheet versions. The changes include updating the CSS stylesheet version in multiple HTML files, adding a new CSS class for dropdown spacing, and refactoring the InboxFilterWrapper and PlanInbox components to support a more structured filtering approach. These modifications improve the user interface and filter management for the health micro UI.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/example/public/index.html
health/micro-ui/web/public/index.html
Updated CSS stylesheet version from 0.2.32 to 0.2.33
health/micro-ui/web/micro-ui-internals/packages/css/src/components/microplan.scss Added new CSS class .gap-between-dropdowns for vertical dropdown layout
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js - Added new state variable filterValues
- Introduced handleDropdownChange method
- Updated filter and dropdown handling logic
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js Updated selectedFilter state to use an object with multiple filter properties

Possibly related PRs

Suggested reviewers

  • nipunarora-eGov
  • jagankumar-egov

Poem

🐰 Filters dancing, dropdowns gleam,
Code hops along a stylish stream
Version bumped with gentle care
UI magic beyond compare!
Rabbit's code, a joyful dream 🌈

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca2b8cc and f04ebfb.

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

Pattern **/*.js: check

📓 Learnings (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 59-59: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


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

'key' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 151-151: 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 (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (2)

72-72: 🧹 Nitpick (assertive)

Remove commented-out code if no longer needed
Leaving this commented statement in place could cause confusion. If it’s not needed, consider removing it.

- // setSelectedValue(selectedValue); // Clear the selection

Likely invalid or redundant comment.


58-59: 🛠️ Refactor suggestion

Use const and avoid Object.prototype.hasOwnProperty
Since you never reassign key, it’s safer to declare it as const rather than let. Also, to avoid potential prototype pollution issues, prefer Object.hasOwn() over filterValues[key].hasOwnProperty(...).

Below is an example fix:

-for (let key in filterValues) {
-  if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('code')) {
+for (const key in filterValues) {
+  if (filterValues[key] && typeof filterValues[key] === 'object' && Object.hasOwn(filterValues[key], 'code')) {
     filtersToApply[key] = filterValues[key].code;
   } else {
     filtersToApply[key] = filterValues[key];
   }
 }
⛔ Skipped due to learnings
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🧰 Tools
🪛 Biome (1.9.4)

[error] 59-59: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


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

'key' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@abishekTa-egov abishekTa-egov changed the title FEATURE/HCMPRE-1709 FEATURE/HCMPRE-1709: Accessibility Dropdown Dec 30, 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

🔭 Outside diff range comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

Line range hint 497-509: Duplicated conditional logic
Similar logic checking if selectedFilter.status === "VALIDATED" appears in multiple places. Consider refactoring into a helper function to avoid duplication.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f15a96 and a27755b.

⛔ 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 (5)
  • 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/components/InboxFilterWrapper.js (3 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (15 hunks)
  • health/micro-ui/web/public/index.html (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js

[error] 375-375: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 141-141: 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 (12)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (3)

3-4: Adherence to the retrieved learnings about optionsKey looks good
The usage of "name" as the optionKey on the RadioButtons and Dropdown ensures consistency with the local transformation of options.


58-58: Good use of filterValues when applying filters
Passing the entire filterValues object to the parent (props.onApplyFilters) aligns with the updated multi-filter approach.


64-65: Appropriate reset of filterValues in clearFilters
The reset logic correctly clears all filter properties, ensuring a consistent default filter state.

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

36-36: Initialization of selectedFilter with multiple properties
Using an object structure for filters allows for better scalability and organization of multiple filtering criteria.


Line range hint 123-135: Status-based UI handling
The logic to hide or show tabs based on selectedFilter.status especially for "VALIDATED" is clear. Ensure that any future statuses also get appropriately handled here.


174-178: Passing new filter fields to usePlanSearchWithCensus
Expanding the filter fields (onRoadCondition, terrain, securityQ1, securityQ2) ensures comprehensive filtering. Confirm that these parameter names match the backend expectation.


213-216: Consistent usage of filter properties
The object destructuring approach for including new fields (terrain, onRoadCondition, etc.) keeps the data consistent with the updated selectedFilter.


384-393: Validate the selected state in workflow
Ensure that the selectedFilter.status is present in the workflowData?.states array to avoid runtime errors if an unexpected status is set.


511-517: Combining filter updates
Merging the incoming filterValue with the existing prev object ensures incremental updates. This approach is well-suited for multi-filter criteria.


531-536: Safe handling of activeFilter when clearing
Setting selectedFilter.status to the first key of activeFilter is reasonable. However, ensure activeFilter always has at least one key to avoid errors.

health/micro-ui/web/micro-ui-internals/example/public/index.html (1)

15-15: Version update of the CSS stylesheet
The update from 0.2.32 to 0.2.33 is straightforward and presumably includes minor style adjustments for the health UI.

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

13-13: CSS version alignment across the codebase
Ensuring that all references to the digit-ui-health-css stylesheet use the same version (0.2.33) supports predictable styling across all environments.

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

♻️ Duplicate comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

123-129: 🛠️ Refactor suggestion

Ensure consistent optionsKey usage across dropdowns.

Based on previous learnings, optionsKey should be set to "name" consistently across all dropdowns. Currently, some dropdowns use "code" which could lead to inconsistent behavior.

-optionKey={"code"}
+optionKey={"name"}

Also applies to: 135-141, 157-163

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a27755b and afb8820.

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

Pattern **/*.js: check

📓 Learnings (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 62-62: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


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

'key' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 154-154: 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 (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

145-166: ⚠️ Potential issue

Add missing key prop to mapped components.

React requires a unique key prop for elements in an array to optimize rendering and maintain component state correctly.

 return (
-  <LabelFieldPair vertical>
+  <LabelFieldPair vertical key={`security-question-${index}`}>
     <TextBlock body={t(`MP_SECURITY_QUESTION ${index + 1}`)} />

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

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

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 31, 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

🔭 Outside diff range comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (2)

Line range hint 123-135: Watch out for repeated toggle logic
This useEffect toggles the tab when status is "VALIDATED". Notice that similar logic also appears later (lines 497-509), potentially duplicating behavior.


Line range hint 497-509: Consolidate duplicate validation logic
This block repeats the “VALIDATED” handling logic seen at lines 123-135. Consider extracting into a helper function or consolidating the checks to avoid invocation errors and ease maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afb8820 and ca2b8cc.

📒 Files selected for processing (2)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (4 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (15 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

📓 Learnings (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1847
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js:308-314
Timestamp: 2024-11-18T04:35:51.535Z
Learning: In `PlanInbox.js`, the variable `planWithCensus?.StatusCount[selectedFilter]` is always defined in the given context, so null checks are unnecessary.
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 59-59: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


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

'key' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 151-151: 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/PlanInbox.js

[error] 375-375: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

🔇 Additional comments (12)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (9)

36-36: Initialize multi-field filter object
Storing multiple filter criteria in a single state object is a neat approach for managing them collectively.


375-375: Simplify the ternary expression
You can replace selectedFilter?.status ? true : false with !!selectedFilter?.status for succinctness.

🧰 Tools
🪛 Biome (1.9.4)

[error] 375-375: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


393-393: Fallback assignment looks good
Using availableActions || [] ensures no null references and maintains a consistent list structure.


430-430: Safe default for assigned count
Using planWithCensus?.StatusCount[selectedFilter?.status] || 0 gracefully handles missing map keys. This is a reasonable fallback behavior.


438-438: Dependency array
Updating on changes to planWithCensus, selectedFilter?.status, and activeLink ensures the effect re-runs appropriately.


444-444: Re-fetch conditions
Watching selectedFilter?.status, activeLink, censusJurisdiction, and limitAndOffset is logical to refresh data upon these changes.


511-517: Merging filters
Merging new filter properties into previous state ensures incremental updates without losing other fields. Good approach.


531-536: Verify partial filter clearing
By only resetting the status to the first active key, other fields like onRoadCondition or terrain remain set. If the intention is to clear all fields, consider resetting the entire filter object.


807-813: Consider a more scalable approach to status-action checks
As more statuses or actions may be introduced, a configuration-driven or map-based approach could reduce repeated conditionals. This has been noted previously.

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

79-84: Implementation of handleDropdownChange is clear and concise
This function effectively updates filter values for multiple dropdowns. The approach is modular and easy to maintain.


151-151: Add a unique key prop to the mapped <LabelFieldPair> element
A unique key improves React’s rendering efficiency and prevents potential reordering issues. This comment mirrors a prior suggestion, so it is marked as a duplicate.

- <LabelFieldPair vertical>
+ <LabelFieldPair vertical key={index}>
    ...
  </LabelFieldPair>
🧰 Tools
🪛 Biome (1.9.4)

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


58-59: 🛠️ Refactor suggestion

Use const and Object.hasOwn() instead of let and hasOwnProperty
Declaring key as let is unnecessary since it's never reassigned, and calling hasOwnProperty directly can be replaced with Object.hasOwn() to avoid potential prototype pollution hazards.

- for (let key in filterValues) {
-   if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('name')) {
+ for (const key in filterValues) {
+   if (filterValues[key] && typeof filterValues[key] === 'object' && Object.hasOwn(filterValues[key], 'name')) {
      filtersToApply[key] = filterValues[key].name;
    } else {
      filtersToApply[key] = filterValues[key];
    }
  }
⛔ Skipped due to learnings
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🧰 Tools
🪛 Biome (1.9.4)

[error] 59-59: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


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

'key' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)

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