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

Re-design Encounter Card #10579

Merged

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Feb 12, 2025

Proposed Changes

@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

Summary by CodeRabbit

  • New Features

    • Upgraded the encounter information display with refreshed icons, dynamic badge styling, and a reorganized grid layout for improved responsiveness and visual clarity.
  • Style

    • Streamlined text styling in the encounter type description for a cleaner presentation.
  • Chores

    • Introduced new encounter icons and constants to enhance functionality related to encounter displays.

image

@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner February 12, 2025 18:31
Copy link
Contributor

coderabbitai bot commented Feb 12, 2025

Walkthrough

This pull request updates two key components. In the EncounterCard component, a Button now wraps a Link to handle navigation, new icons are introduced (while some old icons are removed), and the badge rendering is enhanced with updated sizes and conditional styling. The layout has been refactored to use Card and grid wrappers for encounter details. Additionally, the CreateEncounterForm component has a minor change to remove a duplicate styling class, streamlining its markup.

Changes

File(s) Change Summary
src/components/Facility/EncounterCard.tsx Replaces the Link component with a Button wrapping a Link, introduces new icons (BadgeCheck, Eye), removes old icons (BedSingle, CareIcon), updates badge rendering (switching to BadgeCheck with size change), and restructures the layout using Card, CardContent, and a grid for dynamic encounter details.
src/components/Encounter/CreateEncounterForm.tsx Removes a duplicate text-xs class from the encounter type description div, simplifying the class list without affecting functionality.
src/common/constants.tsx Adds imports for several icons from lucide-react, introduces a new constant encounterIcons that maps keys to icon imports, and imports EncounterClass for type alignment.

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

I’m a little rabbit coding with glee,
Hopping through changes rapidly.
A Button wraps a Link so neat,
Grid and Card make details complete.
Icons dance and classes align—
Our code sings a joyful design! 🐰✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 58cfb52 and 156f2ac.

📒 Files selected for processing (2)
  • src/common/constants.tsx (2 hunks)
  • src/components/Facility/EncounterCard.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/Facility/EncounterCard.tsx
  • src/common/constants.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)

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 Feb 12, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit d9498e2
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67b8564f01ec1d0008ef86fc
😎 Deploy Preview https://deploy-preview-10579.preview.ohc.network
📱 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

🧹 Nitpick comments (2)
src/components/Facility/EncounterCard.tsx (2)

58-103: Consider adjusting mobile margins.

The layout improvements look great, but the mx-3 class on mobile viewports might cause content overflow or uneven spacing.

Consider this adjustment:

-                  <div key={i} className="w-full mx-3 sm:w-auto">
+                  <div key={i} className="w-full px-3 sm:w-auto sm:px-0">

104-117: Streamline button styling.

While the button placement and icon addition improve usability, the styling approach could be more consistent.

Consider removing the explicit border style and relying on the variant:

-                className="p-2 border border-black"
+                className="p-2"

This will maintain consistency with your design system's button styling.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d9bf2c7 and 90de3f1.

📒 Files selected for processing (1)
  • src/components/Facility/EncounterCard.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/components/Facility/EncounterCard.tsx (3)

2-3: LGTM! Clean dependency management.

The switch from Link to Button+navigate and the addition of UI components align well with the card redesign objectives.

Also applies to: 8-9


22-31: Great improvement to visual hierarchy!

The new card structure with the left border and positioned badge creates an elegant timeline-like visualization for encounters.


33-56: Excellent status visualization improvements!

The enhanced badges with:

  • Contextual colors (green for completed, purple for in-progress)
  • Consistent icon usage
  • Improved spacing and padding
    make the encounter status much more intuitive and visually appealing.

@bodhish
Copy link
Member

bodhish commented Feb 14, 2025

@AdityaJ2305 please add screenshot or demo video for your PR's so that its really easier for the reviewer to see what chagned visually.

@AdityaJ2305
Copy link
Contributor Author

Screenshot 2025-02-14 at 4 38 12 PM

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/Facility/EncounterCard.tsx (3)

36-51: Simplify badge conditional rendering.

The badge implementation can be simplified by extracting the conditional styles into a utility function or constant.

Consider refactoring to:

+ const getBadgeStyles = (status: string) => ({
+   background: completedEncounterStatus.includes(status)
+     ? "bg-green-100 text-green-800 border-green-200"
+     : "bg-purple-100 text-indigo-800 border-purple-200",
+   icon: completedEncounterStatus.includes(status)
+     ? <BadgeCheck className="w-4 h-4 text-teal-700" />
+     : <CircleDashed className="w-4 h-4 text-indigo-800" />
+ });

  <Badge
    variant="outline"
    className={cn(
      "inline-flex gap-2 py-1",
-     completedEncounterStatus.includes(encounter.status)
-       ? "bg-green-100 text-green-800 border-green-200"
-       : "bg-purple-100 text-indigo-800 border-purple-200",
+     getBadgeStyles(encounter.status).background
    )}
  >
-   {completedEncounterStatus.includes(encounter.status) ? (
-     <BadgeCheck className="w-4 h-4 text-teal-700" />
-   ) : (
-     <CircleDashed className="w-4 h-4 text-indigo-800" />
-   )}
+   {getBadgeStyles(encounter.status).icon}
    {t(`encounter_status__${encounter.status}`)}
  </Badge>

34-34: Standardize spacing units.

The layout uses inconsistent spacing units:

  • p-4 sm:p-2 in CardContent
  • mx-3 in grid items
    Consider using rem units consistently for better maintainability.
- <CardContent className="p-4 sm:p-2 space-y-4">
+ <CardContent className="p-4 space-y-4">

- <div className="w-full mx-3 sm:w-auto">
+ <div className="w-full mx-4 sm:w-auto">

Also applies to: 61-62


104-117: Improve button implementation.

The button implementation can be enhanced in several ways:

  1. Extract the onClick handler
  2. Use the design system's button variants instead of custom border styles

Consider refactoring to:

+ const handleViewEncounter = () => {
+   navigate(`/facility/${encounter.facility.id}/encounter/${encounter.id}/updates`);
+ };

  <div className="w-full py-2 bg-gray-100 px-2">
    <Button
      variant="outline"
-     onClick={() =>
-       navigate(
-         `/facility/${encounter.facility.id}/encounter/${encounter.id}/updates`,
-       )
-     }
-     className="p-2 border border-black"
+     onClick={handleViewEncounter}
+     className="p-2"
    >
      <Eye className="mr-2 h-4 w-4" />
      {t("view_encounter")}
    </Button>
  </div>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d1c63a and 99c200d.

📒 Files selected for processing (1)
  • src/components/Facility/EncounterCard.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test
  • GitHub Check: cypress-run (1)
🔇 Additional comments (1)
src/components/Facility/EncounterCard.tsx (1)

1-16: LGTM! Well-organized imports.

The imports are logically grouped and all imported components are utilized effectively in the code.

Copy link
Contributor

@Jacobjeevan Jacobjeevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The font size of card contents (facility, start date etc) relative to other elements in the page is a bit off 🤔 But other than that, lgtm.

image

@AdityaJ2305
Copy link
Contributor Author

@nihal467 , I've added the icon sync with encounter class like we do have it in "Initiate Patient Encounter" form .

  • Keep the in-progress / active ones on the top

I'm not able to understand above point

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Feb 19, 2025
Copy link

Conflicts have been detected against the base branch. Please merge the base branch into your branch.
cc: @AdityaJ2305

See: https://docs.ohc.network/docs/contributing#how-to-resolve-merge-conflicts

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, minor thing

@rithviknishad rithviknishad added reviewed reviewed by a core member and removed needs review labels Feb 20, 2025
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/common/constants.tsx (1)

369-376: Consider using a more intuitive icon for emergency encounters.

While most icon mappings are intuitive, using Building2 for emergency encounters (emer) might not immediately convey urgency. Consider using a more appropriate icon like Siren or AlertTriangle from the lucide-react library to better represent emergency situations.

 export const encounterIcons = {
   imp: BedDouble,
   amb: Ambulance,
   obsenc: Stethoscope,
-  emer: Building2,
+  emer: AlertTriangle, // or Siren for better representation of emergency
   vr: MonitorSmartphone,
   hh: Home,
 } as const satisfies Record<EncounterClass, LucideIcon>;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 573acf2 and 58cfb52.

📒 Files selected for processing (2)
  • src/common/constants.tsx (2 hunks)
  • src/components/Facility/EncounterCard.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Facility/EncounterCard.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test
  • GitHub Check: cypress-run (1)
🔇 Additional comments (1)
src/common/constants.tsx (1)

1-9: LGTM! Well-organized imports.

The new imports are properly organized and grouped by their sources.

Also applies to: 13-13

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Feb 21, 2025
Copy link

Conflicts have been detected against the base branch. Please merge the base branch into your branch.
cc: @AdityaJ2305

See: https://docs.ohc.network/docs/contributing#how-to-resolve-merge-conflicts

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Feb 21, 2025
@nihal467
Copy link
Member

LGTM

@rithviknishad rithviknishad merged commit 569fecb into ohcnetwork:develop Feb 21, 2025
16 of 17 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
reviewed reviewed by a core member tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Green Progress Bar for Completed Status Only Visible on Hover
5 participants