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

Fix: Added location for linked facility #9383

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Dec 11, 2024

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Screenshot

Screenshot 2024-12-11 at 7 37 20 PM

Merge Checklist

  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews

Summary by CodeRabbit

  • New Features
    • Enhanced display of facility names with improved styling, including bold names and smaller gray district and state names for better user context.
    • Improved visual alignment and styling of facility buttons for a more user-friendly interface.
  • Bug Fixes
    • Updated handling of facility selection to ensure proper functionality when setting a home facility.

@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner December 11, 2024 14:13
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes in the pull request focus on the LinkedFacilities component, enhancing the user interface by improving the display of facility information. The component now uses a new Button import, replaces the previous ButtonV2, and adjusts the layout to show facility names in bold with district and state names rendered conditionally. The button containers have increased padding and height, and the CareIcon components have been resized for better visibility. The overall functionality and error handling mechanisms remain unchanged.

Changes

Files Change Summary
src/components/Users/LinkedFacilities.tsx Updated to enhance facility display, changed ButtonV2 to Button, adjusted layout and icon sizes.

Assessment against linked issues

Objective Addressed Explanation
Show facility name and location (Issue #9367)

Suggested labels

needs review, tested

Suggested reviewers

  • Jacobjeevan
  • rithviknishad

Poem

🐇 In the fields where facilities bloom,
Names now dance with district's tune.
A click brings homes, a seamless flow,
With every detail, our knowledge will grow!
So hop along, and let us cheer,
For clearer paths are finally here! 🌼


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. (Experiment)
  • @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 11, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit f18c840
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/675af9c270ac1400082c774d
😎 Deploy Preview https://deploy-preview-9383--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
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

🧹 Outside diff range and nitpick comments (1)
src/components/Users/LinkedFacilities.tsx (1)

249-252: Maintain consistency in null checking patterns

While the implementation is functionally correct, it uses a different pattern for null checking compared to the linked facilities implementation. Consider using optional chaining for consistency:

-          {homeFacility.district_object &&
-            `, ${homeFacility.district_object.name}`}
+          {homeFacility.district_object?.name &&
+            `, ${homeFacility.district_object.name}`}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 113dddd and 476f36e.

📒 Files selected for processing (1)
  • src/components/Users/LinkedFacilities.tsx (2 hunks)
🔇 Additional comments (2)
src/components/Users/LinkedFacilities.tsx (2)

202-206: LGTM! Implementation aligns with requirements

The addition of district information is well-implemented with proper null checking using optional chaining. The formatting with the comma separator provides a clean and readable display.


202-206: Verify FacilityModel type definition

Let's verify that the district_object property is properly defined in the FacilityModel type and consistently used across the codebase.

Also applies to: 249-252

✅ Verification successful

Based on the search results, I can now generate the final response as we have found both the FacilityModel interface definition and the usage of district_object across the codebase.

Property district_object is properly defined and consistently used

The FacilityModel interface in src/components/Facility/models.tsx shows that district_object is an optional property, and its usage in LinkedFacilities.tsx is consistent with the type definition. The property is used with optional chaining (?.) throughout the codebase, which is the correct pattern for accessing optional properties.

  • The property is used consistently with optional chaining in multiple components
  • The pattern facility.district_object?.name is used similarly in other components like UserListView, PatientDetails, etc.
  • The type definition and usage align with TypeScript's best practices for optional properties
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check FacilityModel type definition and usage
echo "Checking FacilityModel type definition..."
ast-grep --pattern 'interface FacilityModel {
  $$$
  district_object?: {
    $$$
  }
  $$$
}'

echo "Checking district_object usage patterns..."
rg "district_object" --type typescript

Length of output: 358


Script:

#!/bin/bash
# Let's try a different approach to find the type definition and usage

# First, let's find all TypeScript/TSX files that might contain the FacilityModel definition
echo "Searching for FacilityModel definition..."
rg "FacilityModel" -A 5 -B 5

# Then, let's look for district_object usage in all ts/tsx files
echo -e "\nSearching for district_object usage..."
fd -e ts -e tsx -x rg "district_object" {}

Length of output: 65513

@Jacobjeevan
Copy link
Contributor

Hmm, maybe we could display the local body name as well...but both in a tool tip? 🤔 I'll ping the design channel for ideas.

@Jacobjeevan
Copy link
Contributor

@AdityaJ2305 Try this:

image

@AdityaJ2305
Copy link
Contributor Author

@AdityaJ2305 Try this:

image

👍

@AdityaJ2305
Copy link
Contributor Author

AdityaJ2305 commented Dec 12, 2024

@Jacobjeevan, Done

Screenshot 2024-12-12 at 4 13 03 PM

@rithviknishad
Copy link
Member

rithviknishad commented Dec 12, 2024

  1. gray shade is the right shade that we use from figma. Let's switch to using that?
  2. Ensure font weights are similar to the one in the design.
  3. The "Add Facility" button, let's swap that to using Button from shadcn UI instead of ButtonV2
  4. Let's use full width cards in mobile view. Looks weird in mobile as of now.
image

@AdityaJ2305
Copy link
Contributor Author

@rithviknishad

Screenshot 2024-12-12 at 8 14 22 PM Screenshot 2024-12-12 at 8 13 51 PM

@rithviknishad
Copy link
Member

Awesome!

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

🧹 Outside diff range and nitpick comments (3)
src/components/Users/LinkedFacilities.tsx (3)

204-214: Consider adding tooltips for facility names and locations

While the location display is well-implemented, long facility/location names might get truncated. Consider adding tooltips to show the full names on hover, as suggested in the PR comments.

 <div className="text-sm text-black p-2 font-bold flex-1">
+  <div title={`${facility.name}`}>
     {facility.name}
+  </div>
   {facility.district_object?.name && (
-    <div className="text-sm text-gray-500 font-medium">
+    <div className="text-sm text-gray-500 font-medium" 
+         title={`${facility.district_object.name}${facility.state_object?.name ? `, ${facility.state_object.name}` : ''}`}>
       {facility.district_object?.name}
       {facility.district_object?.name &&
         facility.state_object?.name &&
         ", "}
       {facility.state_object?.name}
     </div>
   )}
 </div>

Also applies to: 258-268


302-302: Improve mobile layout spacing

The flex column layout for mobile is good, but consider adjusting the spacing for better visual hierarchy:

-<div className="flex flex-col sm:flex-row gap-3">
+<div className="flex flex-col sm:flex-row gap-4 sm:gap-3">

-<div className="flex flex-col sm:flex-row gap-3">
+<div className="flex flex-col sm:flex-row gap-4 sm:gap-3">

-<div className="flex flex-col sm:flex-row flex-wrap gap-3">
+<div className="flex flex-col sm:flex-row flex-wrap gap-4 sm:gap-3">

Also applies to: 332-332, 344-344


316-326: Reconsider custom button padding

The button migration to Shadcn UI looks good, but the custom padding might override Shadcn's default styling system:

 <Button
   variant="primary"
   size="lg"
   name="Add"
   id="link-facility"
-  className="mt-1 rounded-lg px-6 py-[23px] text-base"
+  className="mt-1 text-base"
   onClick={() => linkFacility(userData.username, facility)}
   disabled={!authorizeForHomeFacility}
 >
   {t("add_facility")}
 </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 ab51657 and a1ea309.

📒 Files selected for processing (1)
  • src/components/Users/LinkedFacilities.tsx (6 hunks)
🔇 Additional comments (2)
src/components/Users/LinkedFacilities.tsx (2)

6-6: LGTM: Button component migration

The migration to Shadcn UI's Button component aligns with the design system standardization.


218-218: LGTM: Consistent icon sizing

The icon size changes to text-xl are consistent and improve visibility.

Also applies to: 280-280

@rithviknishad rithviknishad merged commit ed48ece into ohcnetwork:develop Dec 12, 2024
21 checks passed
Copy link

@AdityaJ2305 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.

List facility details in the user facilites page
3 participants