-
Notifications
You must be signed in to change notification settings - Fork 532
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
Fix: Facility Creation Form: Pincode Autofill Overwrites Pre-filled Geographic Data & Added Similar Approach in User Creation Form #10166
Conversation
WalkthroughThe pull request introduces enhancements to organization and user-related forms across multiple components. The changes focus on improving the handling of organization hierarchy, particularly in the Facility and User creation forms. A new function Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/Facility/FacilityForm.tsx (1)
58-65
: Consider moving utility function to a shared location.The
extractHierarchyLevels
function is well-implemented but could be useful in other components. Consider moving it to a utility file for reusability.Additionally, consider adding error handling for malformed data:
function extractHierarchyLevels(org: Organization | undefined): Organization[] { const levels: Organization[] = []; + if (!org) return levels; while (org && org.level_cache >= 0) { + if (!org.name) { + console.warn('Malformed organization data detected'); + break; + } levels.unshift(org as Organization); org = org.parent as Organization | undefined; } return levels; }src/components/Users/UserForm.tsx (1)
274-286
: Consider reusing theextractHierarchyLevels
function.The organization level management could be simplified by reusing the
extractHierarchyLevels
function fromFacilityForm.tsx
. This would ensure consistent hierarchy handling across forms.Apply this change after moving
extractHierarchyLevels
to a shared location:useEffect(() => { - const levels: Organization[] = []; - if (org) levels.push(org); + const levels = extractHierarchyLevels(org); setSelectedLevels(levels); }, [org, organizationId]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/components/Facility/FacilityForm.tsx
(2 hunks)src/components/Users/UserForm.tsx
(4 hunks)src/pages/Organization/OrganizationUsers.tsx
(1 hunks)src/pages/Organization/components/AddUserSheet.tsx
(2 hunks)
🔇 Additional comments (4)
src/pages/Organization/components/AddUserSheet.tsx (1)
23-23
: LGTM! Clean implementation of organization context.The addition of the
organizationId
prop and its propagation to theUserForm
component is well-structured and type-safe.Also applies to: 30-30, 55-55
src/pages/Organization/OrganizationUsers.tsx (1)
70-70
: LGTM! Proper propagation of organization context.The
id
is correctly passed asorganizationId
to theAddUserSheet
component.src/components/Facility/FacilityForm.tsx (1)
Line range hint
205-224
: LGTM! Improved pincode autofill logic.The changes effectively prevent overwriting pre-filled geographic data when there's a district match. The cleanup of the autofill notification timer is properly handled.
However, let's verify the district name matching logic:
✅ Verification successful
District name matching logic is correctly implemented ✅
The district matching logic is robust and reliable because:
- District organizations are properly filtered by type and parent organization
- Names are matched using data from a single source (pincode API)
- Error cases and loading states are properly handled
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential district name variations that might affect matching # Search for district name comparisons in the codebase rg -A 5 'level.name === districtOrg.name' # Search for district organization handling ast-grep --pattern 'districtOrg = $_'Length of output: 628
Script:
#!/bin/bash # Find Organization type definition and related interfaces ast-grep --pattern 'interface Organization' ast-grep --pattern 'type Organization' # Find extractHierarchyLevels implementation ast-grep --pattern 'function extractHierarchyLevels' ast-grep --pattern 'const extractHierarchyLevels' # Find districtOrg initialization rg -A 3 'const.*districtOrg'Length of output: 1083
Script:
#!/bin/bash # Examine the hook implementation and related utilities cat src/hooks/useStateAndDistrictFromPincode.ts # Find related district/state organization utilities rg -g '!*.test.*' -g '!*.spec.*' "districtOrgs" -A 5Length of output: 2969
src/components/Users/UserForm.tsx (1)
610-615
: LGTM! Clean form integration.The
GovtOrganizationSelector
integration is well-implemented with proper form value management and event handling.
LGTM |
@Rishith25 Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
@rithviknishad Can you assign story points to this |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
Release Notes
New Features
Improvements
Technical Updates
organizationId
across multiple components to support more granular organization-level interactions