-
Notifications
You must be signed in to change notification settings - Fork 538
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
GovtSelector isLoading Spinner #10105
GovtSelector isLoading Spinner #10105
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
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/pages/Organization/components/GovtOrganizationSelector.tsx (2)
Line range hint
71-84
: LGTM! Consider enhancing accessibility.The implementation successfully achieves the PR objective by showing the loading spinner alongside the dropdown. The flex layout ensures proper alignment and spacing.
Consider adding the
aria-busy
attribute to improve accessibility:- <div className="flex items-center gap-2"> + <div className="flex items-center gap-2" aria-busy={isLoading}>
72-72
: Consider adding a tooltip to the loading indicator.Adding a tooltip would help users understand what's being loaded.
- {isLoading && <Loader2 className="h-6 w-6 animate-spin" />} + {isLoading && ( + <Loader2 + className="h-6 w-6 animate-spin" + title={t('SYSTEM__loading_organizations')} + /> + )}
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 (1)
src/hooks/useGovtOrganizationLevel.ts (1)
Line range hint
38-47
: Consider adding error handling for the query.The query could fail due to network issues or API errors. Consider destructuring and handling the
error
state fromuseQuery
to provide appropriate feedback to users.- const { data: organizations, isFetching } = useQuery({ + const { data: organizations, isFetching, error } = useQuery({ queryKey: ["organizations-level", parentId, searchQuery], queryFn: query.debounced(organizationApi.list, { queryParams: { org_type: "govt", parent: parentId, name: searchQuery || undefined, limit: 200, }, ...headers, }), }); + + // Handle error state + if (error) { + console.error('Failed to fetch organizations:', error); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/hooks/useGovtOrganizationLevel.ts
(2 hunks)src/pages/Organization/components/GovtOrganizationSelector.tsx
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/pages/Organization/components/GovtOrganizationSelector.tsx
🔇 Additional comments (2)
src/hooks/useGovtOrganizationLevel.ts (2)
38-38
: Good choice usingisFetching
instead ofisLoading
!The rename from
isLoading
toisFetching
is more semantically accurate for React Query's state management. This better supports the UI requirement of showing the loading spinner alongside the dropdown during background refreshes.Also applies to: 77-77
Line range hint
42-46
: Verify the impact of the 200 item limit.The query is limited to 200 results. Please verify if this limit is sufficient for all use cases and whether pagination should be implemented.
✅ Verification successful
200 item limit is appropriate for organization selector dropdowns
The limit is used in organization level selector components that render dropdown menus, not paginated lists. A 200 item limit is reasonable for dropdown UI/UX, as:
- Displaying more items would degrade dropdown performance
- Users typically don't need to scroll through more than 200 organizations
- The search functionality in these components helps users find specific organizations quickly
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if there are any instances where the results might hit the 200 limit rg -A 5 "limit.*200" .Length of output: 32995
Script:
#!/bin/bash # Find components using these hooks and check for pagination implementation echo "=== Components using the hooks ===" rg -B 2 -A 2 "useGovtOrganizationLevel|useOrganizationLevel" --type ts --type tsx echo -e "\n=== Pagination related code near hook usage ===" rg -B 5 -A 5 "pagination|Pagination|pageSize|currentPage" . --type ts --type tsx echo -e "\n=== Error handling related to results limit ===" rg -B 3 -A 3 "error.*limit|limit.*error|too many|maximum|exceeded" . --type ts --type tsxLength of output: 643
Script:
#!/bin/bash # Find components using these hooks echo "=== Hook usage patterns ===" ast-grep --pattern 'const $_ = useGovtOrganizationLevel($$$)' ast-grep --pattern 'const $_ = useOrganizationLevel($$$)' echo -e "\n=== Pagination related code ===" rg "pagination|Pagination|pageSize|currentPage" echo -e "\n=== Error handling patterns ===" rg "error.*limit|limit.*error|too many|maximum|exceeded" # Find any comments or documentation about the limit echo -e "\n=== Comments about limits ===" rg -B 2 -A 2 "\/\/.*limit|\/\*.*limit|\*.*limit|#.*limit" .Length of output: 10099
@Jacobjeevan 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! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
isLoading
toisFetching
for clarity