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

HCMPRE-1766: App Configuration Integration With Data Type Meta Data And Localisation #2186

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

Conversation

nabeelmd-eGov
Copy link
Contributor

@nabeelmd-eGov nabeelmd-eGov commented Feb 3, 2025

  • User Mapping issue fixes
  • fix lowest Hierarchy boundary selection
  • fi localisation code
  • Added Localisation Parent context for central localise storage for app
  • comment local
  • comment local
  • comment local
  • adhoc fix
  • adhoc fix
  • fix selecting field
  • localisation table switch to currentLocale
  • moving all app screen code to one place
  • changes

Choose the appropriate template for your PR:

Feature PR

Feature Request

JIRA ID

Module

Description

Related Issues


Bugfix PR

Bugfix Request

JIRA ID

Module

Description

Root Cause

Related Issues


Release PR

Summary by CodeRabbit

  • New Features
    • Introduced an interactive localization management interface with a tabbed translation table.
    • Enhanced form fields with tooltips and info displays for improved user guidance.
    • Added a new popup for localization management within configuration screens.
  • Refactor
    • Streamlined localization search and update workflows.
    • Removed a legacy sliding panel component to simplify the overall interface.

@nabeelmd-eGov nabeelmd-eGov requested a review from a team as a code owner February 3, 2025 11:51
Copy link
Contributor

coderabbitai bot commented Feb 3, 2025

📝 Walkthrough

Walkthrough

This pull request reorganizes the campaign manager module by updating component import paths and registrations, while removing unused components. New localization functionalities are introduced through additional hooks, services, and context providers. Enhancements include modifications to the UI components to support popups, localization updates, and improved rendering logic. Several new components and custom hooks (e.g., for searching localization and managing missing keys) are added to streamline localization management within the application.

Changes

File(s) Change Summary
health/.../campaign-manager/src/Module.js Updated import paths for AppConfigurationWrapper, added import for AppLocalisationWrapper, and modified component registration and module code formatting.
health/.../campaign-manager/src/components/SidePanel.js Removed the SidePanel component entirely.
health/.../campaign-manager/src/hooks/(index.js, useSearchLocalisation.js, services/searchLocalisationService.js) Added new localization hook useSearchLocalisation, introduced searchLocalisationService for API calls, and updated the hooks index to include the new hook in the campaign object.
health/.../campaign-manager/src/pages/employee/appConfigurationScreen/(AppConfigurationWrapper.js, AppFieldComposer.js, AppFieldScreenWrapper.js, AppLocalisationTable.js, AppLocalisationWrapper.js, DrawerFieldComposer.js, useCustomT.js) Enhanced and added localization support by modifying AppConfigurationWrapper (popup and reducer updates), updating AppFieldComposer and AppFieldScreenWrapper with new props and localization logic, and adding new components (AppLocalisationTable, AppLocalisationWrapper) and custom hook (useCustomT) for managing localization state and display.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant Query as useSearchLocalisation Hook
    participant Service as searchLocalisationService
    participant API as API Service

    UI->>Query: Trigger localization search
    Query->>Service: Call searchLocalisationService with params
    Service->>API: Request localization data
    API-->>Service: Return data/error
    Service-->>Query: Provide response
    Query-->>UI: Deliver localization results
Loading
sequenceDiagram
    participant User as User
    participant Wrapper as AppConfigurationWrapper
    participant Popup as Popup Component

    User->>Wrapper: Click button to open popup
    Wrapper->>Wrapper: Toggle showPopUp state to true
    Wrapper->>Popup: Render popup
    User->>Popup: Click submit/close button
    Popup->>Wrapper: Trigger state update
    Wrapper->>Wrapper: Toggle showPopUp state to false
Loading

Possibly related PRs

  • added popup for boundary summary #1525: The changes in the main PR, specifically the introduction of a showPopUp state variable in the AppConfigurationWrapper, are related to the addition of a similar showPopUp state variable in the BoundaryDetailsSummary component of the retrieved PR.
  • fixed targetvalidation and added no results in boundary #1768: The changes in the main PR are related to the modifications in the Module.js file, specifically regarding the registration of components, as both PRs involve updates to the componentsToRegister object within the same file.
  • fixed draft issue #1737: The changes in the main PR are related to the modifications in the Module.js file, specifically regarding the registration of components in the componentsToRegister object, as both PRs involve updates to component imports and registrations within the same file.

Poem

I'm a bunny in the codefield, hopping with glee,
Changes here and there, as sleek as can be.
Imports rearranged and hooks in a row,
Localisation magic now starts to flow.
With popups and context, the code sings its tune,
Hooray to the changes—my heart's in a swoon! 🐰🌟

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

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 (3)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js (1)

133-190: Remove commented code blocks.

Large blocks of commented code should be removed to improve code maintainability. If this code needs to be referenced later, consider moving it to a separate documentation file or tracking it in version control history.

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldScreenWrapper.js (1)

28-236: Consider decomposing the component for better maintainability.

The component handles multiple responsibilities (tabs, steps, fields, headers). Consider breaking it down into smaller, focused components:

  • TabManager
  • StepManager
  • FieldManager
  • HeaderFieldManager

This would improve:

  • Code organization
  • Testing
  • Reusability
  • Maintenance

Would you like me to help create a plan for decomposing this component?

🧰 Tools
🪛 Biome (1.9.4)

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


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


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


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


[error] 105-105: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


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


[error] 113-113: 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] 115-134: 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] 138-172: 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/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js (1)

40-355: Consider extracting common patterns to reduce code duplication.

The switch statement contains significant code duplication across cases, particularly in the LabelFieldPair and delete button implementation.

Consider extracting these common patterns into separate components:

  1. Create a reusable DeleteButton component
  2. Create a reusable FieldLabel component that handles the label, mandatory marker, and tooltip
  3. Create a reusable FieldWrapper component that handles the InfoCard and LabelFieldPair

This would significantly reduce code duplication and improve maintainability.

🧰 Tools
🪛 Biome (1.9.4)

[error] 80-95: 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] 136-152: 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] 185-201: 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] 233-249: 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] 281-297: 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] 328-344: 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] 102-102: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 159-159: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 208-208: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 256-256: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 353-353: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


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

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

(lint/correctness/noChildrenProp)


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

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

(lint/correctness/noChildrenProp)


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

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

(lint/correctness/noChildrenProp)


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

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

(lint/correctness/noChildrenProp)


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

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

(lint/correctness/noChildrenProp)


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

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

(lint/correctness/noChildrenProp)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 621dc5f and 2800922.

📒 Files selected for processing (12)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/Module.js (3 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SidePanel.js (0 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/index.js (2 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/services/searchLocalisationService.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useSearchLocalisation.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppConfigurationWrapper.js (6 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js (8 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldScreenWrapper.js (5 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppLocalisationTable.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppLocalisationWrapper.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js (5 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/useCustomT.js (1 hunks)
💤 Files with no reviewable changes (1)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SidePanel.js
🧰 Additional context used
📓 Path-based instructions (11)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/index.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useSearchLocalisation.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/services/searchLocalisationService.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldScreenWrapper.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppLocalisationWrapper.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppLocalisationTable.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/useCustomT.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppConfigurationWrapper.js (1)

Pattern **/*.js: check

🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldScreenWrapper.js

[error] 115-134: 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/campaign-manager/src/pages/employee/appConfigurationScreen/AppLocalisationWrapper.js

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


[error] 51-51: Use Number.POSITIVE_INFINITY instead of the equivalent global.

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

(lint/style/useNumberNamespace)


[error] 52-52: Use Number.POSITIVE_INFINITY instead of the equivalent global.

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

(lint/style/useNumberNamespace)

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/useCustomT.js

[error] 13-13: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js

[error] 18-18: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 21-21: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 40-40: 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/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js

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

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

(lint/correctness/noChildrenProp)


[error] 102-102: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


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

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

(lint/correctness/noChildrenProp)


[error] 159-159: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


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

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

(lint/correctness/noChildrenProp)


[error] 208-208: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


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

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

(lint/correctness/noChildrenProp)


[error] 256-256: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


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

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

(lint/correctness/noChildrenProp)


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

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

(lint/correctness/noChildrenProp)


[error] 353-353: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


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

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppConfigurationWrapper.js

[error] 270-270: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 271-271: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


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

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

(lint/correctness/noChildrenProp)


[error] 265-265: 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] 284-292: 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] 293-301: 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 (7)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/useCustomT.js (1)

1-1: LGTM!

The import statement correctly imports the required context hook.

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js (1)

269-269: Handle browser compatibility for crypto.randomUUID().

The crypto.randomUUID() method might not be supported in all browsers.

Consider using a fallback implementation:

-                          id: crypto.randomUUID(),
+                          id: crypto.randomUUID?.() || Math.random().toString(36).substring(2),

Run this script to check browser compatibility:

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldScreenWrapper.js (1)

137-172: LGTM! Localization props are properly implemented.

The fields mapping correctly uses useCustomT for localizing various text fields.

🧰 Tools
🪛 Biome (1.9.4)

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


[error] 138-172: 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/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js (1)

376-376: Verify the necessity of componentRef.

The component uses a ref but doesn't seem to utilize it. If it's not being used, consider removing it.

✅ Verification successful

Component ref usage verification

The componentRef is defined and assigned to an element via ref={componentRef}, but no further usage (like accessing componentRef.current) is evident in the file. If there's no planned DOM manipulation or additional functionality that requires this ref, it appears safe to remove it.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any usage of componentRef in the codebase
rg -l "componentRef" .

Length of output: 159


Script:

#!/bin/bash
# Search for any reference to componentRef.current in the file to see if the ref is actively used
rg "componentRef\.current" ./health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js

Length of output: 165


Script:

#!/bin/bash
# Search for any JSX usage where componentRef is assigned as a ref to an element.
rg "ref\s*=\s*{componentRef}" ./health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js

Length of output: 286


Script:

#!/bin/bash
# Using escaped curly braces to accurately search for JSX usage assigning componentRef as a ref attribute
rg "ref\s*=\s*\\{componentRef\\}" ./health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/AppFieldComposer.js

Length of output: 195

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useSearchLocalisation.js (1)

4-10: LGTM! Well-structured custom hook.

The hook follows React Query best practices with proper query key construction and configuration handling.

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/services/searchLocalisationService.js (1)

41-45: LGTM! Robust error handling.

The error handling is well-implemented with proper extraction of error details and structured error response.

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/index.js (1)

22-22: LGTM! Clean integration of the new hook.

The useSearchLocalisation hook is properly imported and integrated into the campaign object.

Also applies to: 52-52

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 4, 2025
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: 5

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2800922 and 070c99a.

📒 Files selected for processing (2)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js (5 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/useCustomT.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/useCustomT.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js (1)

Pattern **/*.js: check

🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js

[error] 18-18: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 21-21: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


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


[error] 85-85: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)

⏰ Context from checks skipped due to timeout of 10000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
🔇 Additional comments (5)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/useCustomT.js (2)

1-3: LGTM! Hook follows React conventions.

The import and hook declaration follow React best practices.


14-20: LGTM! Good handling of missing keys and fallbacks.

The implementation properly handles:

  1. Finding localization entries
  2. Adding missing keys
  3. Providing fallbacks when needed
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationScreen/DrawerFieldComposer.js (3)

11-23: Remove unreachable break statements or simplify the switch.

The return statements in this switch already exit the function, making the subsequent break statements at lines 18 and 21 unreachable. These lines can be safely removed. This mirrors a previous review comment about simplifying the entire switch to a single expression, so marking as a repeated suggestion.

  switch (panelItem?.label) {
    case "infoText":
    case "label":
    case "helpText":
    case "innerLabel":
-      return drawerState?.[panelItem?.label];
-      break;
    default:
-      return false;
-      break;
  }
🧰 Tools
🪛 Biome (1.9.4)

[error] 18-18: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


[error] 21-21: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)


40-40: Simplify boolean conversion.

Using a ternary expression to convert a value to a boolean is unnecessary. This change was pointed out previously, so it’s considered a repeated suggestion.

-            isCheckedInitially={drawerState?.[panelItem.label] ? true : false}
+            isCheckedInitially={Boolean(drawerState?.[panelItem.label])}
🧰 Tools
🪛 Biome (1.9.4)

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


270-270: Ensure environment support for crypto.randomUUID().

crypto.randomUUID() may not be supported in older browsers or certain Node versions. Confirm its compatibility in your target environment or provide a fallback if needed.

✅ Verification successful

Compatibility of crypto.randomUUID() is well-supported in modern environments.
Based on the latest web query results:

  • Browsers:

    • Chrome: Supported since v92
    • Firefox: Supported since v95
    • Safari: Supported since v15
    • Edge: Supported since v92
    • Opera: Supported from v78
    • Note: Requires HTTPS/secure context.
  • Node.js:

    • Experimental support starting from v14.17
    • Initial/stable implementations noted from v15.6
    • Fully stable in v16.x and later

For projects targeting modern browsers and current Node.js LTS versions, using crypto.randomUUID() is appropriate. If legacy support is a concern, consider adding a polyfill.

🏁 Scripts executed

The following scripts were executed for the analysis:

Web query:

Which browsers and Node.js versions support `crypto.randomUUID()` natively?

Length of output: 8196

Comment on lines +4 to +7
if (!code) {
console.warn("useCustomT: code parameter is required");
return "";
}
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 using a proper logging solution.

While the parameter validation is good, using console.warn directly might not be ideal for production environments. Consider:

  1. Using a proper logging service/utility
  2. Making the warning message more descriptive
-    console.warn("useCustomT: code parameter is required");
+    const message = `useCustomT: 'code' parameter is required but received ${typeof code}`;
+    Digit.Utils.Logger.warn(message);
📝 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
if (!code) {
console.warn("useCustomT: code parameter is required");
return "";
}
if (!code) {
const message = `useCustomT: 'code' parameter is required but received ${typeof code}`;
Digit.Utils.Logger.warn(message);
return "";
}

Comment on lines +8 to +13
const { locState, addMissingKey } = useAppLocalisationContext();
const currentLocale = Digit?.SessionStorage.get("initData")?.selectedLanguage || "en_IN";
if (!Array.isArray(locState)) {
console.warn("useCustomT: locState is not an array");
return "";
}
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)

Enhance error handling for context and locale.

The current implementation could be more robust:

  1. The context destructuring assumes values will exist
  2. Locale retrieval could use more defensive programming
  3. Similar to above, console.warn should be replaced
-  const { locState, addMissingKey } = useAppLocalisationContext();
+  const context = useAppLocalisationContext();
+  if (!context) {
+    Digit.Utils.Logger.error('useCustomT: Localisation context is undefined');
+    return '';
+  }
+  const { locState, addMissingKey } = context;
-  const currentLocale = Digit?.SessionStorage.get("initData")?.selectedLanguage || "en_IN";
+  const currentLocale = Digit?.SessionStorage?.get?.("initData")?.selectedLanguage || "en_IN";
📝 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 { locState, addMissingKey } = useAppLocalisationContext();
const currentLocale = Digit?.SessionStorage.get("initData")?.selectedLanguage || "en_IN";
if (!Array.isArray(locState)) {
console.warn("useCustomT: locState is not an array");
return "";
}
const context = useAppLocalisationContext();
if (!context) {
Digit.Utils.Logger.error('useCustomT: Localisation context is undefined');
return '';
}
const { locState, addMissingKey } = context;
const currentLocale = Digit?.SessionStorage?.get?.("initData")?.selectedLanguage || "en_IN";
if (!Array.isArray(locState)) {
console.warn("useCustomT: locState is not an array");
return "";
}

Comment on lines +119 to +133
{state?.MASTER_DATA?.DrawerPanelConfig?.map((panelItem, index) => {
if (isFieldVisible(panelItem)) {
return (
<div>
<RenderField
panelItem={panelItem}
drawerState={drawerState}
setDrawerState={setDrawerState}
state={state}
updateLocalization={updateLocalization}
/>
</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)

Add a key prop to the mapped elements.

When rendering an array of elements with .map(), each child should have a unique key to avoid React warnings and ensure stable element identity.

-            <div>
+            <div key={panelItem?.label ?? index}>
📝 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
{state?.MASTER_DATA?.DrawerPanelConfig?.map((panelItem, index) => {
if (isFieldVisible(panelItem)) {
return (
<div>
<RenderField
panelItem={panelItem}
drawerState={drawerState}
setDrawerState={setDrawerState}
state={state}
updateLocalization={updateLocalization}
/>
</div>
);
}
})}
{state?.MASTER_DATA?.DrawerPanelConfig?.map((panelItem, index) => {
if (isFieldVisible(panelItem)) {
return (
<div key={panelItem?.label ?? index}>
<RenderField
panelItem={panelItem}
drawerState={drawerState}
setDrawerState={setDrawerState}
state={state}
updateLocalization={updateLocalization}
/>
</div>
);
}
})}

Comment on lines +111 to +115
const isFieldVisible = (field) => {
// If visibilityEnabledFor is empty, the field is always visible
if (field?.visibilityEnabledFor?.length === 0) return true;
return field?.visibilityEnabledFor?.includes(drawerState?.type); // Check if current drawerState type matches
};
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

Action: Ensure safe handling of visibilityEnabledFor property usage

The current search only shows its usage in one file, and there is no evidence elsewhere in the repository that guarantees it is always initialized to an array. Without additional guarantees (such as default values or explicit type checking), an undefined or non-array value could cause runtime issues.

Please ensure that the data structure providing visibilityEnabledFor is controlled to be an array. If not, consider providing a fallback (e.g., using field?.visibilityEnabledFor ?? []) or adding runtime type-checks.

🔗 Analysis chain

Verify that visibilityEnabledFor is always an array.

If visibilityEnabledFor is undefined or not an array, calling .includes() can yield unexpected results or undefined. Ensure it’s guaranteed to be an array or use a safe fallback.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Searching references for "visibilityEnabledFor" to confirm it's always an array type.
rg -A 5 'visibilityEnabledFor'

Length of output: 1548

Comment on lines +83 to +85
default:
return null;
break;
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 unreachable break after return.

In the default case, the return null; statement makes the subsequent break; unreachable. Removing it helps avoid confusion and keeps the code clean.

    default:
      return null;
-      break;
📝 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
default:
return null;
break;
default:
return null;
🧰 Tools
🪛 Biome (1.9.4)

[error] 85-85: This code is unreachable

... because this statement will return from the function beforehand

(lint/correctness/noUnreachable)

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