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

Location Availability display fix #10749

Merged
merged 1 commit into from
Feb 21, 2025
Merged

Location Availability display fix #10749

merged 1 commit into from
Feb 21, 2025

Conversation

amjithtitus09
Copy link
Contributor

@amjithtitus09 amjithtitus09 commented Feb 21, 2025

@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

    • Expanded English localization with new translations for “available” and “unavailable” statuses.
  • Refactor

    • Updated the location display to show status and availability using localized text, ensuring a more dynamic and context-aware presentation.

image

@amjithtitus09 amjithtitus09 requested a review from a team as a code owner February 21, 2025 13:07
Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

This pull request adds two new localization keys ("available" and "unavailable") in the English JSON file. It updates the LocationCard component to use the translation function for both status and availability text, incorporating logic to determine availability based on the presence of a current encounter. Additionally, the LocationList interface is enhanced with an optional current_encounter property to support this functionality.

Changes

File(s) Change Summary
public/locale/en.json Added two new key-value pairs: "available": "Available" and "unavailable": "Unavailable"
src/pages/Facility/.../LocationCard.tsx Updated status badge to use translation (t(location.status)) and modified availability logic to check current_encounter and translate accordingly
src/types/location/location.ts Added an optional property current_encounter?: Encounter to the LocationList interface, with the necessary import

Sequence Diagram(s)

sequenceDiagram
  participant LC as LocationCard
  participant Loc as Location Object
  participant t as Translation Function

  LC->>Loc: Retrieve status and current_encounter
  alt current_encounter exists
    LC->>t: Translate "unavailable"
  else
    LC->>t: Translate "available"
  end
  LC->>t: Translate status (t(location.status))
  Note right of LC: Render badges with translated text.
Loading

Possibly related PRs

Suggested labels

needs review, needs testing

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

I'm a rabbit with a hop and a cheer,
New keys in JSON make the changes clear.
The badges now speak in many a tongue,
With translations and logic so finely spun.
Hop along, dear coder, for improvements are near!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 21, 2025

Deploy Preview for care-ohc ready!

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

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: f57dbca
Status: ✅  Deploy successful!
Preview URL: https://d556c5af.care-fe.pages.dev
Branch Preview URL: https://location-minor-fixes.care-fe.pages.dev

View logs

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between da97c2f and f57dbca.

📒 Files selected for processing (3)
  • public/locale/en.json (2 hunks)
  • src/pages/Facility/settings/locations/components/LocationCard.tsx (1 hunks)
  • src/types/location/location.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • public/locale/en.json
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test
  • GitHub Check: cypress-run (1)
🔇 Additional comments (4)
src/types/location/location.ts (2)

1-1: LGTM!

The import statement follows the project's import pattern and is necessary for the new current_encounter property.


46-51: LGTM!

The current_encounter property is correctly added:

  • Follows the file's snake_case naming convention
  • Properly marked as optional
  • Type is correctly specified as Encounter
src/pages/Facility/settings/locations/components/LocationCard.tsx (2)

98-100: LGTM!

The variant logic correctly reflects availability:

  • Default variant when location is available (no current encounter)
  • Destructive variant when location is unavailable (has current encounter)

103-105:

✅ Verification successful

Verify translation keys for availability text.

Ensure that translation keys exist for "available" and "unavailable" in the translation files.

Run the following script to check the translation files:


🏁 Script executed:

#!/bin/bash
# Description: Check if translation keys exist for availability text

# Search for availability translation keys
echo "Searching for availability translation keys..."
rg -i '"available"\s*:|"unavailable"\s*:' public/locale/

Length of output: 265


Translation keys verified successfully.

The translation keys for "available" and "unavailable" are correctly defined in public/locale/en.json, so the conditional rendering in src/pages/Facility/settings/locations/components/LocationCard.tsx (lines 103-105) is using the proper keys. No further changes are needed.

@@ -92,17 +92,17 @@ export function LocationCard({ location, onEdit, className }: Props) {
location.status === "active" ? "default" : "secondary"
}
>
{location.status}
{t(location.status)}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify translation keys for status values.

Ensure that translation keys exist for all possible status values: "active", "inactive", and "unknown".

Run the following script to check the translation files:


🏁 Script executed:

#!/bin/bash
# Description: Check if translation keys exist for status values

# Search for status values in translation files
echo "Searching for status translation keys..."
rg -i '"active"\s*:|"inactive"\s*:|"unknown"\s*:' public/locale/

Length of output: 660


Translation Keys Verification: "inactive" key missing in some locales

The check confirms that while "active" and "unknown" are translated consistently across all locales, the "inactive" key is defined only in the English translation file (public/locale/en.json). Please verify whether a fallback to English is acceptable or if you need to add translations for "inactive" in the other languages (hi, kn, ta, ml).

Copy link

cypress bot commented Feb 21, 2025

CARE    Run #4919

Run Properties:  status check passed Passed #4919  •  git commit f57dbca1c2: Location Availability display fix
Project CARE
Branch Review location-minor-fixes
Run status status check passed Passed #4919
Run duration 07m 37s
Commit git commit f57dbca1c2: Location Availability display fix
Committer Amjith Titus
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 11
View all changes introduced in this branch ↗︎

@nihal467 nihal467 added tested reviewed reviewed by a core member and removed needs testing labels Feb 21, 2025
@Jacobjeevan Jacobjeevan merged commit 8debf38 into develop Feb 21, 2025
25 checks passed
@Jacobjeevan Jacobjeevan deleted the location-minor-fixes branch February 21, 2025 14:52
Copy link

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

3 participants