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

Adds support for searching for OrganizationSelector and fix scroll for dropdown in sheet #9620

Merged
merged 6 commits into from
Dec 31, 2024

Conversation

rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Dec 31, 2024

Proposed Changes

  • Fixes autocomplete scroll when descendant of sheet
  • Adds support for searching for OrganizationSelector
  • Add Schedule tab in app sidebar

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Enhanced Autocomplete component with search capability
    • Added debounced search functionality for organization selection
    • New localization keys added for pluralized terms across multiple languages
    • Conditional rendering of "schedules" link in the sidebar based on user presence
  • Improvements

    • Improved search input handling with 500ms debounce
    • Updated Popover component interaction model
    • Updated navigation button names in the Calendar component
  • Deprecations

    • Deprecated useSlug and useSlugs functions in favor of usePathParams

Copy link
Contributor

coderabbitai bot commented Dec 31, 2024

Walkthrough

The pull request introduces enhancements to the Autocomplete component by adding a new optional onSearch prop, which allows the component to handle search input changes. Additionally, a new hook, useDebouncedState, is implemented in the OrganizationSelector to manage the searchQuery state with a debounce effect. The localization files are updated for consistency in terminology, particularly regarding patient search terms. Other components, such as AppSidebar, are modified to accommodate user-specific links, and deprecated hooks are replaced with recommendations for alternatives.

Changes

File Change Summary
src/components/ui/autocomplete.tsx Added optional onSearch prop to AutocompleteProps interface, updated Autocomplete component to handle search input changes, set Popover modal property to true
src/pages/Organization/components/OrganizationSelector.tsx Introduced useDebouncedState hook, updated query keys to include searchQuery, modified Autocomplete component to use onSearch for updating search state
public/locale/en.json Added key "schedules" and re-added "quantity_required" key
public/locale/hi.json Updated key "search_patient" to "search_patients"
public/locale/kn.json Updated key "search_patient" to "search_patients"
public/locale/ml.json Updated key "search_patient" to "search_patients"
public/locale/ta.json Updated key "search_patient" to "search_patients"
src/components/ui/sidebar/app-sidebar.tsx Updated generateFacilityLinks function to accept an optional user parameter and modified link names to lowercase
src/hooks/useSlug.ts Deprecated useSlug and useSlugs functions, recommending usePathParams instead
src/components/ui/calendar.tsx Updated navigation button component names from IconLeft and IconRight to PreviousMonthButton and NextMonthButton

Possibly related PRs

  • New Cypress Test for HCX Workflow in the platform #9007: The changes in the main PR regarding the onSearch prop in the Autocomplete component are related to the updates in the OrganizationSelector component, which now uses the onSearch prop to manage the searchQuery state, linking it directly to the search input functionality.
  • Fix wrong terminology used in place of Log Update #9089: The changes in the main PR that enhance the Autocomplete component's functionality with search capabilities are related to the updates in the localization files, which include new keys for logging functionalities that may be used in conjunction with the search features.
  • Fix: Duplicate network requests in Patient Details page #9297: The modifications in the main PR that streamline the fetchNotes function in the PatientNotesList component are relevant to the changes in the EncounterHistory and Notes components, which also involve updates to how patient data is fetched and displayed.
  • New Patient Search and Register UI #9400: The new patient search and registration UI in the main PR is related to the changes in the PatientFilter component, which introduces a structured search interface for filtering patients by multiple fields, enhancing the overall patient management experience.
  • Adds useMutation compatible utility function and other abstractions #9463: The introduction of a mutate utility function in the main PR aligns with the updates in the App.tsx file that enhance error handling and caching mechanisms, indicating a broader effort to improve API interactions across the application.

Suggested labels

needs review

Suggested reviewers

  • rithviknishad
  • Jacobjeevan
  • shivankacker

Poem

🐰 In the fields where queries bloom,
A rabbit hops, dispelling gloom.
With onSearch and debounce in play,
Searching for answers, come what may.
Autocomplete dances, swift and bright,
Guiding us all through the digital night! 🔍


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

netlify bot commented Dec 31, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 2c2c87f
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6773c6a48b3c7e000859b015
😎 Deploy Preview https://deploy-preview-9620--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

cloudflare-workers-and-pages bot commented Dec 31, 2024

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2c2c87f
Status: ✅  Deploy successful!
Preview URL: https://a10e773c.care-fe.pages.dev
Branch Preview URL: https://rithviknishad-enhancements.care-fe.pages.dev

View logs

@rithviknishad rithviknishad changed the title Enhancements Adds support for searching for OrganizationSelector and fix scroll for dropdown in sheet Dec 31, 2024
@rithviknishad rithviknishad marked this pull request as ready for review December 31, 2024 09:57
@rithviknishad rithviknishad requested a review from a team as a code owner December 31, 2024 09:57
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: 0

🧹 Nitpick comments (3)
src/components/ui/autocomplete.tsx (2)

30-30: Check for optional onSearch before invocation
Currently, onSearch is defined as optional, but the code does not guard against the case where it may be undefined. Consider adding a safety check (e.g., onSearch?.(value)) in any place where the function is called to avoid possible runtime errors.


75-75: Use safe invocation for onValueChange
If onValueChange is bound directly to onSearch, ensure that onSearch is valid (e.g., via onSearch?.(val)) to prevent errors when onSearch is not provided.

src/pages/Organization/components/OrganizationSelector.tsx (1)

37-37: Adjust the 500ms debounce if needed
A 500ms debounce might be slightly high for fast typists, but it’s generally acceptable. If user feedback suggests decreased responsiveness, consider lowering it to around 300ms.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c2ce66e and c317874.

📒 Files selected for processing (2)
  • src/components/ui/autocomplete.tsx (3 hunks)
  • src/pages/Organization/components/OrganizationSelector.tsx (5 hunks)
🔇 Additional comments (6)
src/components/ui/autocomplete.tsx (2)

40-40: Prop grouping looks good
Passing onSearch and other props together follows a clear pattern. No issues here.


48-48: Verify modal={true} usage for Popover
Using modal mode can significantly change focus and keyboard interaction. Ensure that this behavior is expected. If not, consider removing or setting it to false.

src/pages/Organization/components/OrganizationSelector.tsx (4)

10-11: New import for useDebouncedState
The introduction of useDebouncedState is a neat approach to controlling the frequency of queries. Consider ensuring the hook is well-tested for different edge cases (e.g., empty string, rapidly changing input).


48-53: Good practice including searchQuery in queryKey
Including searchQuery in queryKey ensures the query result properly reflects the user input. This approach is essential for correct React Query caching and refetch behavior.


65-71: Consistent application of searchQuery for nested organizations
Mirroring the same logic for the child-level organizations keeps the UI consistent. Continue verifying that the derived organizations truly reflect all search-related updates.


162-162: Directly passing setSearchQuery to onSearch
This direct pass works well, especially with the debounce approach. Just be mindful that no additional formatting of the search input is done before updating the state.

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Dec 31, 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: 0

🧹 Nitpick comments (1)
src/hooks/useSlug.ts (1)

20-20: Consider consistency in the deprecation message.

The @deprecated tag for useSlugs is slightly different than for useSlug. Verify that this minor formatting difference in documentation is intentional. Ideally, both deprecation tags should consistently reference the new function.

Proposed minimal fix:

- * * @deprecated use `usePathParams` instead
+ * @deprecated use `usePathParams` instead
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c317874 and 64b1e57.

📒 Files selected for processing (7)
  • public/locale/en.json (4 hunks)
  • public/locale/hi.json (2 hunks)
  • public/locale/kn.json (2 hunks)
  • public/locale/ml.json (2 hunks)
  • public/locale/ta.json (2 hunks)
  • src/components/ui/sidebar/app-sidebar.tsx (3 hunks)
  • src/hooks/useSlug.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • public/locale/en.json
🔇 Additional comments (11)
src/hooks/useSlug.ts (1)

5-5: Documentation updates look good!

The deprecation notice is helpful in guiding developers toward usePathParams. Ensure that the transition plan (including migration guides) is clearly communicated in the project's documentation so that future maintainers know these functions will eventually be removed or replaced.

src/components/ui/sidebar/app-sidebar.tsx (6)

44-46: Acknowledgment of the TODO and optional user parameter

Including the optional user parameter is a good approach to keep the function flexible until the serializer update. The inline TODO reminds fellow developers of the pending change, which helps maintain overall clarity and direction in the code.


50-50: Ensure link ordering and naming consistency

When defining navigation links, consider how link ordering and naming (singular/plural) are structured across the application. Consistency aids user familiarity. Currently, this looks consistent with app-wide conventions.


58-58: Pluralization alignment with i18n updates

Using t("search_patients") aligns well with the pluralized key introduced in the locale files. This helps maintain consistency across the interface.


69-69: Naming alignment for “organization”

Renaming the link to organization is consistent with the i18n changes. Ensure that any references to capitalized variants are also harmonized across the codebase.


75-81: Conditional sidebar link for “schedules”

Adding this link only if user is defined is sensible. In the future, consider verifying that user.username is not empty or undefined to prevent potential URL or logic errors. Overall, logic is solid here.


186-186: Propagating the user parameter to generateFacilityLinks

Passing the user object ensures that the newly added conditional “schedules” link is constructed accurately. This maintains the single-responsibility of generateFacilityLinks.

public/locale/hi.json (1)

676-676: Pluralization fix for search label

Changing "search_patient" to "search_patients" aligns the Hindi locale with the updated keys in the code. This maintains consistency across different languages and improves clarity for users.

public/locale/kn.json (1)

678-678: Pluralization fix for Kannada locale

Renaming "search_patient" to "search_patients" maintains the pluralized naming convention. This ensures consistency with other languages and the code references.

public/locale/ta.json (1)

676-676: LGTM! Consistent pluralization update.

The change from "search_patient" to "search_patients" aligns with the pluralization updates across localization files.

public/locale/ml.json (1)

677-677: LGTM! Consistent pluralization update.

The change from "search_patient" to "search_patients" maintains consistency with other localization files.

@rithviknishad rithviknishad removed the Deploy-Failed Deplyment is not showing preview label Dec 31, 2024
Copy link

cypress bot commented Dec 31, 2024

CARE    Run #4108

Run Properties:  status check passed Passed #4108  •  git commit 2c2c87f17b: Adds support for searching for `OrganizationSelector` and fix scroll for dropdow...
Project CARE
Branch Review rithviknishad/enhancements
Run status status check passed Passed #4108
Run duration 01m 09s
Commit git commit 2c2c87f17b: Adds support for searching for `OrganizationSelector` and fix scroll for dropdow...
Committer Rithvik Nishad
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 3
View all changes introduced in this branch ↗︎

@nihal467
Copy link
Member

LGTM

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

🧹 Nitpick comments (1)
src/components/ui/calendar.tsx (1)

65-66: Add an aria-label for improved accessibility

When icons are used as interactive elements (in this case, buttons), it's good practice to provide a label for screen readers. This helps visually impaired users navigate the calendar more easily.

Here is an example fix:

 components={{
-  PreviousMonthButton: () => <ChevronLeftIcon className="h-4 w-4" />,
-  NextMonthButton: () => <ChevronRightIcon className="h-4 w-4" />,
+  PreviousMonthButton: () => (
+    <button type="button" aria-label="Previous Month">
+      <ChevronLeftIcon className="h-4 w-4" />
+    </button>
+  ),
+  NextMonthButton: () => (
+    <button type="button" aria-label="Next Month">
+      <ChevronRightIcon className="h-4 w-4" />
+    </button>
+  ),
 }}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 64b1e57 and 2c2c87f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • src/components/ui/calendar.tsx (1 hunks)

@bodhish bodhish merged commit f6ba679 into develop Dec 31, 2024
22 of 23 checks passed
@bodhish bodhish deleted the rithviknishad/enhancements branch December 31, 2024 10:44
Copy link

@rithviknishad 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! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants