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

ui changes and validations for boundary added #2175

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

suryansh-egov
Copy link
Contributor

@suryansh-egov suryansh-egov commented Jan 29, 2025

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

  • Style Updates

    • Updated health module CSS stylesheet from version 0.2.41 to 0.2.42
    • Modified popup wrapper max-width to improve layout responsiveness
  • UI Improvements

    • Added mandatory field indicators for boundary code selections
    • Enhanced validation feedback for data mapping
  • Bug Fixes

    • Improved error handling in campaign setup and data mapping components
    • Removed unnecessary console logging statements

@suryansh-egov suryansh-egov requested a review from a team as a code owner January 29, 2025 06:56
Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

📝 Walkthrough

Walkthrough

This pull request encompasses updates to the health module's web interface, focusing on styling resources and component improvements. The changes include updating the CSS stylesheet version from 0.2.41 to 0.2.42 in multiple HTML files, modifying the popup wrapper width in a SCSS file, and enhancing validation and UI elements in campaign management components. The modifications aim to improve user interface consistency, error handling, and visual feedback across the application.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/example/public/index.html Updated CSS stylesheet version from 0.2.41 to 0.2.42
health/micro-ui/web/public/index.html Updated CSS stylesheet version from 0.2.41 to 0.2.42
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss Modified .digit-popup-wrapper.custom-pop-up-mapping width from fit-content to max-width: 35rem
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js Added mandatory indicators for "Boundary Code" labels
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMapping.js Enhanced validation logic, improved error handling, and button label checks
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js Removed console logging, added try-catch for error handling

Possibly related PRs

Suggested reviewers

  • jagankumar-egov

Poem

🐰 A Rabbit's Ode to UI Delight
Stylesheet dancing, version so bright,
Popups refined with pixel-perfect might,
Boundaries marked with asterisk's glee,
Code cleaned up, errors set free!
Hop, hop, hooray for UI's new height! 🎨✨


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

🔭 Outside diff range comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js (2)

Line range hint 83-120: Enhance form validation and user feedback.

The MultiSelectDropdown is marked as mandatory but lacks proper validation feedback. Consider adding error states and messages when validation fails.

Here's a suggested implementation:

 <MultiSelectDropdown
     variant="nestedmultiselect"
     props={{ className: "data-mapping-dropdown" }}
     t={t}
+    error={selectedBoundary?.length === 0}
+    errorMessage={t("PLEASE_SELECT_BOUNDARY")}
     options={
         Object.values(
         (allSelectedBoundary?.filter((i) => i.type === selectedLevel?.boundaryType) || []).reduce((acc, item) => {
             // ... existing code
         }, {})
         ) || []
     }
     optionsKey={"code"}
     selected={selectedBoundary ? selectedBoundary : []}
     onClose={(value) => {
         const boundariesInEvent = value?.map((event) => event?.[1]);
+        if (!boundariesInEvent?.length) {
+            return; // Prevent setting empty values for mandatory field
+        }
         const values = boundariesInEvent?.map((i) => i?.code)?.join(",")
         const updatedData = { ...newdata, [t(column.name)]: values };
         setNewData(updatedData);
         setSelectedBoundary(boundariesInEvent);
     }}    
     // ... other props
 />
🧰 Tools
🪛 Biome (1.9.4)

[error] 82-82: 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] 84-84: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)


Line range hint 19-26: Improve component structure and error handling.

Consider the following improvements:

  1. Extract the boundary transformation logic into a separate utility function
  2. Add error handling for UUID generation
  3. Separate data transformation from UI rendering

Here's a suggested implementation:

+const transformBoundaryData = (allSelectedBoundary, selectedLevel) => {
+  if (!allSelectedBoundary?.length || !selectedLevel) return [];
+  return Object.values(
+    allSelectedBoundary
+      .filter((i) => i.type === selectedLevel.boundaryType)
+      .reduce((acc, item) => {
+        const { parent, code, type } = item;
+        if (!acc[parent]) {
+          acc[parent] = { code: parent, options: [] };
+        }
+        acc[parent].options.push({ code, type, parent });
+        return acc;
+      }, {})
+  );
+};

+const generateUUID = () => {
+  try {
+    return crypto.randomUUID();
+  } catch (error) {
+    console.error('Failed to generate UUID:', error);
+    return Date.now().toString(); // Fallback
+  }
+};

 useImperativeHandle(ref, () => ({
   getData: () => {
-    return typeOfOperation === "add" ? {...newdata, editable:true, id: crypto.randomUUID()} : {...newdata, editable:true, id: curData?.id};
+    return typeOfOperation === "add" 
+      ? {...newdata, editable: true, id: generateUUID()} 
+      : {...newdata, editable: true, id: curData?.id};
   },
 }));

Then update the MultiSelectDropdown options prop:

-options={
-  Object.values(
-    (allSelectedBoundary?.filter((i) => i.type === selectedLevel?.boundaryType) || []).reduce((acc, item) => {
-      // ... existing reduction logic
-    }, {})
-  ) || []
-}
+options={transformBoundaryData(allSelectedBoundary, selectedLevel)}
🧰 Tools
🪛 Biome (1.9.4)

[error] 66-66: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)

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

Line range hint 1032-1098: Improve UI component consistency and accessibility.

The UI changes show inconsistent button variations and styling:

  1. Some buttons use "secondary" variation while others use "teritiary"
  2. The popup wrapper width is hardcoded

Consider extracting button variations into constants and using CSS variables for widths:

+ const BUTTON_VARIATIONS = {
+   SECONDARY: 'secondary',
+   PRIMARY: 'primary'
+ };

- variation={"secondary"}
+ variation={BUTTON_VARIATIONS.SECONDARY}

+ // In your CSS
+ :root {
+   --popup-max-width: 35rem;
+ }
+ className={"custom-pop-up-mapping"}
+ style={{ maxWidth: 'var(--popup-max-width)' }}
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss (1)

Line range hint 272-295: Add accessibility improvements to the popup.

The popup implementation could benefit from accessibility enhancements:

 .digit-popup-wrapper.custom-pop-up-mapping {
   max-width: 35rem;
+  /* Ensure popup is keyboard navigable */
+  &:focus {
+    outline: 2px solid #0b4b66;
+    outline-offset: 2px;
+  }
+
+  /* Add ARIA attributes in the corresponding JSX */
+  /* aria-modal="true" */
+  /* aria-labelledby="popup-title" */
+  /* role="dialog" */

   .digit-popup-footer {
     padding-top: 0 !important;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c692a06 and 7fc379b.

⛔ 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 (6)
  • health/micro-ui/web/micro-ui-internals/example/public/index.html (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaign.scss (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js (2 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMapping.js (16 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (3 hunks)
  • health/micro-ui/web/public/index.html (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js

[error] 66-66: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)


[error] 84-84: A form label must be associated with an input.

Consider adding a for or htmlFor attribute to the label element or moving the input element to inside the label element.

(lint/a11y/noLabelWithoutControl)

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMapping.js

[error] 50-52: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


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

'validate' is never reassigned.

Safe fix: Use const instead.

(lint/style/useConst)


[error] 796-796: 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] 815-815: 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] 941-941: 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] 960-960: 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)

⏰ Context from checks skipped due to timeout of 10000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
🔇 Additional comments (2)
health/micro-ui/web/micro-ui-internals/example/public/index.html (1)

15-15: Verify CSS version compatibility.

The health CSS package version has been updated to 0.2.40.

Run this script to check for breaking changes:

✅ Verification successful

CSS package version 0.2.40 is properly synchronized

Both HTML files are using the same version of the CSS package, and the package is accessible via unpkg CDN.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in the CSS package

# Get the changelog or release notes
curl -s "https://unpkg.com/@egovernments/[email protected]/CHANGELOG.md" || \
curl -s "https://raw.githubusercontent.com/egovernments/DIGIT-Frontend/develop/micro-ui/web/micro-ui-internals/packages/css/CHANGELOG.md"

# Verify the package exists and is accessible
curl -s -o /dev/null -w "%{http_code}" "https://unpkg.com/@egovernments/[email protected]/dist/index.css"

Length of output: 469


Script:

#!/bin/bash
# Search for other references to the CSS package
rg -l "digit-ui-health-css@" --type html

Length of output: 143


Script:

#!/bin/bash
# Check CSS package versions in both files
echo "=== health/micro-ui/web/public/index.html ==="
rg "digit-ui-health-css@" health/micro-ui/web/public/index.html

echo -e "\n=== health/micro-ui/web/micro-ui-internals/example/public/index.html ==="
rg "digit-ui-health-css@" health/micro-ui/web/micro-ui-internals/example/public/index.html

Length of output: 634

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

13-13: LGTM! Consistent version update.

The health CSS package version update matches the change in example/public/index.html, maintaining consistency across the application.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc379b and 188d637.

⛔ 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 (2)
  • health/micro-ui/web/micro-ui-internals/example/public/index.html (1 hunks)
  • health/micro-ui/web/public/index.html (1 hunks)
⏰ Context from checks skipped due to timeout of 10000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
health/micro-ui/web/public/index.html (1)

13-13: Version update is consistent, but clarification needed.

The CSS version update to 0.2.42 is consistent with the other file. However, the PR objectives mention UI changes and validations for boundary, but we only see CSS version updates in these files.

Could you please clarify:

  1. Where are the boundary validation changes implemented?
  2. Are there additional files that contain these changes?

@jagankumar-egov jagankumar-egov merged commit 7573213 into console Jan 29, 2025
6 of 7 checks passed
@jagankumar-egov jagankumar-egov deleted the FEATURE/HCMPRE-1850-BUG branch January 29, 2025 07:21
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.

3 participants