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

fixed facilitysearch issue #1697

Merged
merged 1 commit into from
Oct 28, 2024
Merged

fixed facilitysearch issue #1697

merged 1 commit 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

  • New Features
    • Introduced a new class for multi-select dropdown styling in the facility UI.
  • Improvements
    • Updated the stylesheet links for the health UI component to the latest version.
    • Enhanced styling capabilities for the SearchJurisdiction component.
  • Bug Fixes
    • Improved safe property access in the facility catchment mapping logic to prevent potential errors.

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

coderabbitai bot commented Oct 28, 2024

📝 Walkthrough

Walkthrough

The pull request includes updates to several files primarily focused on modifying CSS styles and updating the stylesheet links for the health UI component. The HTML files have had their links changed to reference a new version of the CSS package, while the SCSS file introduces new classes and modifies existing ones. Additionally, a JavaScript component has been adjusted for improved styling capabilities without altering functionality.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/example/public/index.html Updated stylesheet link from version 0.1.11 to 0.1.12 for @egovernments/digit-ui-health-css.
health/micro-ui/web/public/index.html Updated stylesheet link from version 0.1.11 to 0.1.12 for @egovernments/digit-ui-health-css.
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss Added new class .searchjurisdiction-multiselectdropdown, modified .facility-popup, and defined new classes for layout.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/SearchJurisdiction.js Removed marginBottom: 0 from LabelFieldPair, added className prop to MultiSelectDropdown.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/useFacilityCatchmentMapping.js Updated property access for facilityType and status to use optional chaining.

Possibly related PRs

  • bug fixes for sandbox #1439: Updates the stylesheet link in the same HTML file as the main PR, indicating a similar type of change related to CSS versioning.
  • Sandbox UI fixes #1442: Updates the stylesheet link in an HTML file for the same CSS package, showing a related change in versioning.
  • resolved HCMPRE-1070,1073-910,1075 #1668: Updates the stylesheet link for the health-related UI components in the same file as the main PR, reflecting a similar change in CSS versioning.
  • my microplan localisation, css fixes #1685: Updates the stylesheet link for the health-related UI components, similar to the main PR's focus on CSS versioning.
  • updated facilitypopup #1689: Introduces several new CSS classes in the facility.scss file, directly related to the changes made in the main PR regarding the health UI component's stylesheet.

Suggested reviewers

  • nipunarora-eGov

Poem

In the garden of code, where styles bloom bright,
A hop and a skip brought changes to light.
New classes were added, and links were refined,
A version upgrade, oh how well-timed!
With each little tweak, our UI takes flight,
A rabbit's delight in the soft moonlight! 🐇✨


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

🧹 Outside diff range comments (6)
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss (2)

Line range hint 1-3: Consider improving the popup's responsive design.

While setting a max-width helps control the popup size, consider these improvements:

  • Replace !important with more specific selectors
  • Add media queries for better mobile responsiveness
  • Use relative units (e.g., vw) for dynamic sizing
.facility-popup {
-  max-width: 85% !important;
+  max-width: min(85%, 1200px);
+  width: 100%;
+  @media screen and (max-width: 768px) {
+    max-width: 95%;
+  }
}

Line range hint 11-13: Consider using design system variables for consistency.

The border color should ideally come from your design system's color palette for better maintainability.

.facility-popup-table-card {
-  border: 1px solid #d6d5d4;
+  border: 1px solid var(--border-color, #d6d5d4);
+  border-radius: var(--border-radius-regular, 4px);
}
health/micro-ui/web/public/index.html (1)

Line range hint 8-14: Consider adding integrity hashes for CDN resources.

The application is loading multiple CSS files from unpkg.com without SHA integrity hashes. This poses a security risk as the content served by the CDN could potentially be compromised.

Consider adding integrity hashes to ensure the authenticity of the loaded resources:

-  <link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.8.2-beta.34/dist/index.css" />
-  <link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-components-css@0.0.2-beta.39/dist/index.css" />
-  <link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-health-css@0.1.12/dist/index.css" />
+  <link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.8.2-beta.34/dist/index.css" 
+        integrity="sha384-[generated-hash]" crossorigin="anonymous" />
+  <link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-components-css@0.0.2-beta.39/dist/index.css"
+        integrity="sha384-[generated-hash]" crossorigin="anonymous" />
+  <link rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-health-css@0.1.12/dist/index.css"
+        integrity="sha384-[generated-hash]" crossorigin="anonymous" />

Additionally, consider:

  1. Using a more stable CDN or self-hosting these assets
  2. Implementing a fallback mechanism in case the CDN is unavailable
  3. Bundling these CSS files with your application for better control and performance
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/useFacilityCatchmentMapping.js (2)

Line range hint 1-1: Fix typo in function name

The function name has a typo: useFcilityCatchmentMapping is missing an 'a'. It should be useFacilityCatchmentMapping.

-const useFcilityCatchmentMapping = (props) => {
+const useFacilityCatchmentMapping = (props) => {

Line range hint 51-56: Add error handling for API failures

The hook returns a revalidate function that does nothing (() => {}). Consider handling API errors and providing proper error state.

 return {
   isLoading,
   isFetching,
   data,
   refetch,
-  revalidate: () => {},
+  error: data?.error,
+  revalidate: refetch,
 };
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/SearchJurisdiction.js (1)

Line range hint 69-87: Consider performance and accessibility improvements.

The boundary selection implementation could benefit from the following enhancements:

  1. Performance:
    • Memoize the filtered boundaries to prevent unnecessary recalculations
    • Batch state updates where possible
  2. Accessibility:
    • Add ARIA labels for screen readers
    • Ensure proper keyboard navigation support

Example implementation:

+const memoizedBoundaryOptions = useMemo(() => {
+  if (!selectedHierarchy) return [];
+  const userBoundaries = Digit.Utils.microplanv1.filterBoundariesByJurisdiction(boundaries, jurisdiction.boundaryCodes);
+  const filteredBoundaries = userBoundaries.filter((row) => row.type === selectedHierarchy.boundaryType);
+  return Digit.Utils.microplanv1.groupByParent(filteredBoundaries);
+}, [selectedHierarchy, boundaries, jurisdiction]);

 <MultiSelectDropdown
   variant={"nestedmultiselect"}
   selected={selectedBoundaries}
   onSelect={handleBoundarySelect}
   className="searchjurisdiction-multiselectdropdown"
+  aria-label={t("SELECT_BOUNDARIES")}
+  role="listbox"
   isSearchable={true}
   t={t}
   addCategorySelectAllCheck={true}
   addSelectAllCheck={true}
-  options={boundaryOptions}
+  options={memoizedBoundaryOptions}
   optionsKey={"name"}
   name={"nestedmultiselectoptions"}
 />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between b67c2a1 and ffc956b.

⛔ 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/pages/employee/facility.scss (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/SearchJurisdiction.js (2 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/useFacilityCatchmentMapping.js (1 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/components/SearchJurisdiction.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

🔇 Additional comments (6)
health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss (2)

Line range hint 5-9: LGTM! Well-structured flex layouts.

The flex layouts for both wrappers are well implemented with appropriate spacing and alignment properties.

Also applies to: 15-19


21-23: LGTM! Clear class naming.

The class name follows a consistent naming convention and the styling is appropriately scoped.

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

19-19: Version update looks good, but needs verification.

The CSS package version update from 0.1.11 to 0.1.12 appears to be related to fixing the facility search issue mentioned in the PR title.

Let's verify if this version contains the necessary changes:

✅ Verification successful

Version update is justified and contains necessary facility search fixes

The git history shows that the CSS package version update from 0.1.11 to 0.1.12 includes recent changes to fix facility search issues:

  • Added new styles for facility popup layout and search results
  • Fixed margin issue in facility search jurisdiction dropdown
  • Improved facility popup table card styling

These changes directly correspond to the PR's objective of fixing facility search issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the changes in the new CSS version and its relation to facility search

# Test: Check for any facility-related CSS changes in the repository
rg -i "facility|search" --type css

Length of output: 16646


Script:

#!/bin/bash
# Let's check the facility.scss file content to understand the CSS changes
cat health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss

# Also check git history for recent changes to facility.scss
git log -p health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/facility.scss

Length of output: 3190

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

14-14: Verify if this CSS update fixes the facility search issue.

The PR description mentions fixing a facility search issue, but this change only updates the health CSS package version. Please clarify how this CSS update addresses the facility search functionality problem.

✅ Verification successful

Based on the git history and code changes, I can now generate a final response:

The CSS version update is related to facility search functionality fixes

The version bump from 0.1.11 to 0.1.12 is directly tied to fixing the facility search issue as evidenced by commit ffc956b which shows:

  1. A fix in the facility search query parameter construction in useFacilityCatchmentMapping.js
  2. The bug was related to incorrect property access in the search query (facilityType and status were missing .name property)

The CSS package update was part of the same commit that fixed this functionality issue.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for related changes in the facility search related files
# and the changelog of the CSS package

# Look for facility search related files
echo "Searching for facility search related files..."
rg -l -i "facilitysearch|facility.?search" 

# Look for package.json files that might reference this CSS package
echo "Checking for package dependencies..."
fd package.json --exec grep -l "digit-ui-health-css"

Length of output: 662


Script:

#!/bin/bash
# Let's check the content of the found files to understand the facility search implementation
# and any potential CSS-related issues

# Check the facility catchment mapping hook
echo "=== Facility Catchment Mapping Hook ==="
cat health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/useFacilityCatchmentMapping.js

# Check the facility mapping config
echo -e "\n=== Facility Mapping Config ==="
cat health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/FacilityMappingConfig.js

# Check the CSS package.json for version history
echo -e "\n=== CSS Package.json ==="
cat health/micro-ui/web/micro-ui-internals/packages/css/package.json

# Check for any recent changes in these files
echo -e "\n=== Recent Git History ==="
git log -p --since="1 month ago" -- \
    health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/useFacilityCatchmentMapping.js \
    health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/FacilityMappingConfig.js \
    health/micro-ui/web/micro-ui-internals/packages/css/package.json

Length of output: 49473

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

Line range hint 13-26: Verify the impact of active filter

The search is filtered by active: true. Ensure this doesn't exclude valid inactive plans that should be visible.

✅ Verification successful

Based on the search results, I can now provide a conclusive response about the active filter's impact:

The active: true filter is correctly implemented and should remain

The codebase shows this is an intentional design pattern used consistently across multiple components for plan employee assignments:

  • In inbox views (PlanInbox.js, PopInbox.js) - Shows only active assignments for approvers
  • In user access management (UserAccess.js) - Filters active assignments for role management
  • In facility catchment mapping (FacilityCatchmentMapping.js) - Shows active assignments for mapping

The system has proper handling for inactive plans through:

  • Explicit toggle functionality in UserAccess.js and RoleTableComposer.js that can switch active status
  • Separate flows for managing active/inactive assignments through the PlanEmployeeAssignment update API
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any inactive plans that should be visible
ast-grep --pattern 'PlanEmployeeAssignmentSearchCriteria {
  $$$
  active: $_,
  $$$
}'

Length of output: 89


Script:

#!/bin/bash
# Let's search for any references to PlanEmployeeAssignmentSearchCriteria in the codebase
rg -A 5 "PlanEmployeeAssignmentSearchCriteria" 

# Also search for any API or service definitions related to plan assignments
rg -A 5 "PlanEmployeeAssignment" 

# Look for any documentation or configuration files mentioning plan visibility rules
fd -e md -e yaml -e json -X rg -l "plan.*visibility|plan.*active"

Length of output: 26821

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

Line range hint 69-87: Verify if the facility search issue is fully resolved.

The changes appear to be purely cosmetic. Given that this PR aims to fix a facility search issue, please verify:

  1. The search functionality works correctly with the selected boundaries
  2. The boundary selection properly filters facilities
  3. The clear/search actions work as expected

Let's check for any related facility search implementations:

✅ Verification successful

Let me check the implementation of handleBoundarySelect and related validation logic:


Based on the code analysis, I can now provide a final response:

The cosmetic changes are appropriate and the search functionality appears to be properly implemented.

The code review reveals:

  1. The boundary selection handler (handleBoundarySelect) correctly processes selected boundaries
  2. The facility search implementation in useFacilityCatchmentMapping.js properly uses the selected boundaries for filtering
  3. The validation utilities include robust boundary validation logic that ensures data integrity

The changes in the PR maintain the existing search functionality while improving the UI layout, which is appropriate for this bugfix.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for facility search related code
echo "Searching for facility search implementations..."
rg -l "facility.*search|search.*facility" --type js

# Check for any error handling or validation related to boundary selection
echo "Checking boundary selection validation..."
rg "handleBoundarySelect|validateBoundary" --type js

Length of output: 2391


Script:

#!/bin/bash
# Check handleBoundarySelect implementation and related code
echo "Checking boundary selection handler implementation..."
rg -A 10 "handleBoundarySelect = \(" health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/SearchJurisdiction.js

# Check facility catchment mapping implementation
echo "Checking facility catchment mapping implementation..."
cat health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/useFacilityCatchmentMapping.js

# Check validation utilities
echo "Checking validation utilities..."
cat health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/utils/utilities.js

Length of output: 18184

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