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

updated facilitypopup #1689

Merged
merged 4 commits into from
Oct 28, 2024
Merged

updated facilitypopup #1689

merged 4 commits into from
Oct 28, 2024

Conversation

Swathi-eGov
Copy link
Contributor

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

Choose the appropriate template for your PR:

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new CSS classes for enhanced layout and styling in the facility popup.
    • Improved the FacilityPopup component with better row selection and a more interactive data table.
    • Added custom styling capability to the SearchJurisdiction component.
    • Enhanced translation support in the TimelinePopUpWrapper component for better localization.
  • Bug Fixes

    • Corrected minor styling issues in the SearchJurisdiction component.

These updates enhance user experience through improved functionality and visual design.

@Swathi-eGov Swathi-eGov requested a review from a team as a code owner October 28, 2024 07:12
Copy link
Contributor

coderabbitai bot commented Oct 28, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces several enhancements to the user interface and functionality of the facility management components. Key changes include the addition of new CSS classes in facility.scss to improve layout and styling, modifications to the FacilityPopup.js component for better row selection and rendering of data, and updates to the SearchJurisdiction.js component to allow for custom styling. These changes collectively aim to enhance the interactivity and usability of the facility management interface.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss - New classes added: .facilitypopup-serach-results-wrapper, .facility-popup-table-card, .facilitypopup-tab-serach-wrapper.
- Modified class: .facility-popup (max-width set to 85% !important).
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js - Updated import statement to include SVG.
- Refactored handleRowSelect method.
- Removed handleSelectAll method.
- Enhanced data table rendering with new properties.
- Adjusted layout with Card components.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/SearchJurisdiction.js - Added style prop to component signature.
- Applied style prop to main wrapper <div>.
- Updated CardLabel components for width adjustments.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/timelinePopUpWrapper.js - Updated label and comment properties in timelineSteps to use translation function t() for improved localization.

Possibly related PRs

  • added facility search #1556: The changes in this PR involve the addition of a new CSS class .facility-popup in the facility.scss file, which directly relates to the modifications made in the main PR where new classes were added to the same file.
  • added jurisdictions in facility serach and updated popinbox #1602: This PR updates the PopInbox component, which is likely related to the facility management context, as it includes modifications to the handling of jurisdictions and integrates with the facility search functionality.
  • Added action bar for pop inbox screen #1622: This PR modifies the PopInboxTable, which is relevant as it may display data related to facilities, and it includes changes that affect how data is rendered, potentially linking it to the styles defined in the main PR.
  • fixed import issue #1676: This PR includes modifications to the UICustomizations.js file, which may relate to the overall styling and configuration of UI components, including those affected by the changes in the main PR.
  • my microplan localisation, css fixes #1685: This PR updates the stylesheet for health-related UI components, which could include styles relevant to the facility management context addressed in the main PR.

Suggested reviewers

  • nipunarora-eGov

Poem

🐇 In the land of CSS and code,
New styles and classes brightly glowed.
Facility popups dance with glee,
With buttons and cards, oh what a spree!
A sprinkle of style, a touch of flair,
In our micro-ui, joy is everywhere! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

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

Line range hint 71-85: Consider adding aria-label for accessibility.

The MultiSelectDropdown would benefit from an aria-label to improve accessibility for screen readers.

Add an aria-label to the MultiSelectDropdown:

          <MultiSelectDropdown
+           aria-label={t("SELECT_BOUNDARIES")}
            variant={"nestedmultiselect"}
            selected={selectedBoundaries}
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/FacilityPopup.js (1)

Line range hint 279-286: Enhance error handling in API mutations

The current error handling could be improved to provide better debugging information and user feedback.

Consider adding error details and logging:

         onError: async (result) => {
-          setShowToast({ key: "error", label: t("ERROR_WHILE_UPDATING_PLANFACILITY"), transitionTime: 5000 });
+          console.error('Plan facility update failed:', result);
+          setShowToast({ 
+            key: "error", 
+            label: t("ERROR_WHILE_UPDATING_PLANFACILITY") + (result?.message ? `: ${result.message}` : ''), 
+            transitionTime: 5000 
+          });
         },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 8c8fdf8 and 614022f.

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

[error] 326-326: 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] 356-356: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)

🔇 Additional comments (6)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/SearchJurisdiction.js (4)

7-7: LGTM: Function signature updated correctly.

The addition of the style prop with a default empty object follows React best practices.


54-54: LGTM: Style prop applied correctly.

The style prop is properly applied to the wrapper div, allowing for flexible styling from parent components.


57-57: LGTM: CardLabel styling is appropriate.

Setting width:100% ensures the label spans the full container width, improving layout consistency.


7-7: Verify style prop usage in parent components.

Let's verify how this component is being used to ensure the style prop is being utilized effectively.

✅ Verification successful

Style prop is being used correctly in parent components

The verification shows that the style prop is being utilized appropriately:

  • In FacilityPopup.js, it's used with specific styling: style={{ padding: "0px" }}
  • Other usages in PopInbox.js and PlanInbox.js don't pass the optional style prop, which is fine since it defaults to an empty object {}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for SearchJurisdiction usage to verify style prop implementation
rg -l "SearchJurisdiction" | xargs rg -A 5 "<SearchJurisdiction"

Length of output: 2459

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

3-3: LGTM: SVG import addition

The SVG component is appropriately imported and used for visual feedback in the selection state UI.


187-192: LGTM: Improved row selection handling

The refactored selection handling is more efficient and maintainable:

  • Directly extracts IDs from event.selectedRows
  • Properly manages both individual and bulk selection states

ashish-egov
ashish-egov previously approved these changes Oct 28, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 28, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

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

Line range hint 8-54: Consider performance and error handling improvements.

The component could benefit from some architectural improvements:

  1. Memoize the steps transformation to prevent unnecessary recalculations:
+ const transformSteps = React.useCallback((instances) => {
+   return instances.map((instance, index) => ({
+     label: t(instance?.state?.applicationStatus || 'NA'),
+     variant: 'completed',
+     subElements: [
+       Digit.Utils.microplanv1.epochToDateTime(instance?.auditDetails?.lastModifiedTime),
+       instance?.assignes?.length > 0 ? instance.assignes[0]?.name : 'NA',
+       instance?.comment ? t(instance.comment) : ''
+     ],
+     showConnector: true
+   }));
+ }, [t]);

 useEffect(() => {
   if (workflowData && workflowData.ProcessInstances) {
-    const steps = workflowData.ProcessInstances.map...
+    const steps = transformSteps(workflowData.ProcessInstances);
     setTimelineSteps(steps);
   }
 }, [workflowData]);
  1. Add error handling:
 const TimelinePopUpWrapper = ({ onClose, businessId, heading }) => {
+  const [error, setError] = useState(null);
   // ... existing code ...

   return (
     <PopUp
       onClose={onClose}
       heading={t(heading)}
       onOverlayClick={onClose}
       children={[
+        error ? (
+          <div className="error-message">{t('ERROR_LOADING_WORKFLOW')}</div>
+        ) :
         isLoading ? <Loader /> :
           <TimelineMolecule ... />
       ]}
     />
   );
 };

Line range hint 7-7: Add PropTypes and JSDoc documentation.

This component would benefit from proper documentation and type checking:

+ import PropTypes from 'prop-types';

+ /**
+  * TimelinePopUpWrapper - A component that displays workflow timeline in a popup
+  * @param {Object} props
+  * @param {Function} props.onClose - Callback function to close the popup
+  * @param {string} props.businessId - Business ID for workflow lookup
+  * @param {string} props.heading - Heading text for the popup
+  * @returns {React.ReactElement}
+  */
 const TimelinePopUpWrapper = ({ onClose, businessId, heading }) => {
   // ... existing code ...
 };

+ TimelinePopUpWrapper.propTypes = {
+   onClose: PropTypes.func.isRequired,
+   businessId: PropTypes.string.isRequired,
+   heading: PropTypes.string.isRequired
+ };
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/SearchJurisdiction.js (1)

Line range hint 41-49: Consider adding error handling for boundary selection.

The handleBoundarySelect function could benefit from additional error handling for malformed event objects.

Consider updating the handler with better error checking:

 const handleBoundarySelect = (selectBoundariesEvent) => {
-    if (!selectBoundariesEvent)
+    if (!selectBoundariesEvent || !Array.isArray(selectBoundariesEvent))
       return
     if (selectBoundariesEvent.length === 0) {
       setSelectedBoundaries([])
       return
     }
 
     const boundariesInEvent = selectBoundariesEvent?.map(event => {
+      if (!Array.isArray(event) || event.length < 2) return null;
       return event?.[1]
-    })
+    }).filter(Boolean)
     setSelectedBoundaries(boundariesInEvent)
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 614022f and 4779fa8.

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

[error] 326-326: 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] 356-356: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)

🔇 Additional comments (8)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/timelinePopUpWrapper.js (1)

Line range hint 36-41: Add safety checks for nested properties and review translation key usage.

While the addition of translations is good, there are a few potential issues to address:

Consider applying these improvements:

 const steps = workflowData.ProcessInstances.map((instance, index) => ({
-    label: t(instance.state.applicationStatus),
+    label: t(instance?.state?.applicationStatus || 'NA'),
     variant: 'completed',
     subElements: [Digit.Utils.microplanv1.epochToDateTime(instance?.auditDetails?.lastModifiedTime),
     instance?.assignes?.length > 0 ? instance.assignes[0]?.name : 'NA',
-    t(`${instance.comment}`)
+    instance?.comment ? t(instance.comment) : ''
     ],
     showConnector: true
 }));

The changes:

  1. Add null checks for nested properties to prevent runtime errors
  2. Remove template literal for comment translation as it's unnecessary and could cause issues with dynamic content
  3. Provide fallback values for missing data
✅ Verification successful

Based on the search results, I can now provide a final response:

The review comment's concerns about translation safety are valid, but the suggested changes need revision.

The codebase shows consistent patterns of handling application status translations:

  1. The applicationStatus is commonly used across the codebase as a workflow state identifier, and it's consistently translated using the t() function.
  2. The current implementation follows the established pattern where status codes are directly translated without template literals.
  3. The comment translation should indeed be handled more safely, but the suggested implementation can be improved.

Here's the recommended improvement:

 const steps = workflowData.ProcessInstances.map((instance, index) => ({
     label: t(instance?.state?.applicationStatus || 'NA'),
     variant: 'completed',
     subElements: [Digit.Utils.microplanv1.epochToDateTime(instance?.auditDetails?.lastModifiedTime),
     instance?.assignes?.length > 0 ? instance.assignes[0]?.name : 'NA',
-    t(`${instance.comment}`)
+    instance?.comment ? t(instance.comment) : '-'
     ],
     showConnector: true
 }));

Key changes:

  • Keep direct translation of applicationStatus as it's a standard workflow state identifier
  • Add null check for state access
  • Improve comment translation with proper null check and a meaningful fallback value
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the translation keys exist in the translation files
echo "Searching for translation files and keys..."
fd -e json . | xargs rg "applicationStatus|comment" -A 5

Length of output: 155


Script:

#!/bin/bash
# Let's try a different approach to find translation files and their content
# First, let's check the directory structure to locate translation files
fd "localization|i18n|translations" --type d

# Then, let's look for any JSON files that might contain translations
fd -e json . -x echo "=== {} ===" -x cat {}

# Additionally, let's check how applicationStatus is used in the codebase
rg "applicationStatus" -B 2 -A 2

# Let's also check for similar timeline components to understand the pattern
ast-grep --pattern 'label: t($_)'

Length of output: 42129

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

7-7: LGTM: Component signature update is well-implemented.

The addition of the style prop with a default empty object follows React best practices and maintains backward compatibility.


54-54: LGTM: Style prop is correctly applied.

The style prop is properly applied to the root div, allowing for flexible styling while maintaining the base "search-wrapper" class.


57-57: LGTM: Consistent styling improvements.

The styling changes improve layout consistency with full-width labels and proper spacing. The previous syntax error with double commas has been fixed.

Also applies to: 69-70

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

3-3: LGTM: Import changes are appropriate

The SVG import addition aligns with its usage in the component for visual feedback.


187-192: LGTM: Improved row selection handling

The refactored row selection logic is more efficient and cleaner. It properly handles both individual and bulk selection states while maintaining a single source of truth for selection state.


409-411: LGTM: Well-implemented toast notification handling

The dynamic toast type determination is clean and handles all cases properly while maintaining good code readability.


356-356: 🧹 Nitpick (assertive)

Use self-closing tag for SVG component

For better readability and consistency with React conventions, use self-closing tags for components without children.

-                      <SVG.DoneAll width={"1.5rem"} height={"1.5rem"} fill={"#C84C0E"}></SVG.DoneAll>
+                      <SVG.DoneAll width={"1.5rem"} height={"1.5rem"} fill={"#C84C0E"} />

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome

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

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