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(native-app): if organ donation errors and there is no data, only show error message #17847

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

thoreyjona
Copy link
Contributor

@thoreyjona thoreyjona commented Feb 5, 2025

What

When organ donation service is down we were accidentally showing half of the data (defaulting to user not being an organ donor even if we know nothing about it) along with an error message, when we should only be showing the error message if we don't have any data.

Screenshots / Gifs

Before:

After:

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • Refactor
    • Improved the organ donation status display so that the input is shown only when the relevant data is available or loading.
    • Updated the donor status label to provide clearer, more descriptive information for users.

@thoreyjona thoreyjona requested a review from a team as a code owner February 5, 2025 22:28
@thoreyjona thoreyjona enabled auto-merge February 5, 2025 22:28
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

The pull request updates the rendering logic within the HealthOverviewScreen component for the organ donation status. The organ donation input field is now conditionally rendered only when the organ donation data is either loading or has been fetched successfully. Additionally, the label for the input field is modified to provide a more descriptive message using internationalized formatting. No changes were made to exported or public entities.

Changes

File(s) Change Summary
apps/.../health/health-overview.tsx Updated conditional rendering for the organ donation status input field; added checks for data loading or availability; enhanced label description using intl.formatMessage.

Sequence Diagram(s)

sequenceDiagram
    participant Screen as HealthOverviewScreen
    participant Data as organDonationRes

    Screen->>Data: Fetch organ donation data
    alt Data is loading or available
        Screen->>Screen: Render organ donation input field with intl-formatted label
    else Data not available
        Screen->>Screen: Do not render input field
    end
Loading

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • snaerseljan

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

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.

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

nx-cloud bot commented Feb 5, 2025

View your CI Pipeline Execution ↗ for commit 1f050bb.

Command Status Duration Result
nx run-many --projects native-app --target test... ✅ Succeeded 7s View ↗
nx run-many --target=lint --projects=native-app... ✅ Succeeded 12s View ↗
nx run-many --target=codegen/frontend-client --... ✅ Succeeded 12s View ↗
nx run-many --target=codegen/backend-schema --a... ✅ Succeeded 21s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-05 22:33:54 UTC

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)
apps/native/app/src/screens/health/health-overview.tsx (1)

555-583: Consider extracting the label and value logic for better maintainability.

While the implementation is functionally correct, the nested ternary operations and string interpolation make the code harder to maintain. Consider extracting this logic into helper functions.

+  const getOrganDonationLabel = () => {
+    if (isOrganDonorWithLimitations) return 'health.organDonation.isDonorWithLimitations'
+    if (isOrganDonor) return 'health.organDonation.isDonor'
+    return 'health.organDonation.isNotDonor'
+  }
+
+  const getOrganDonationDescription = () => {
+    if (isOrganDonorWithLimitations) return 'health.organDonation.isDonorWithLimitationsDescription'
+    if (isOrganDonor) return 'health.organDonation.isDonorDescription'
+    return 'health.organDonation.isNotDonorDescription'
+  }
+
   {isOrganDonationEnabled &&
     (organDonationRes.loading || organDonationRes.data) && (
       <InputRow background>
         <Input
-          label={intl.formatMessage({
-            id: isOrganDonorWithLimitations
-              ? 'health.organDonation.isDonorWithLimitations'
-              : isOrganDonor
-              ? 'health.organDonation.isDonor'
-              : 'health.organDonation.isNotDonor',
-          })}
-          value={`${intl.formatMessage(
-            {
-              id: isOrganDonorWithLimitations
-                ? 'health.organDonation.isDonorWithLimitationsDescription'
-                : isOrganDonor
-                ? 'health.organDonation.isDonorDescription'
-                : 'health.organDonation.isNotDonorDescription',
-            },
-            {
-              limitations: isOrganDonorWithLimitations
-                ? organLimitations?.join(', ')
-                : '',
-            },
-          )}`}
+          label={intl.formatMessage({ id: getOrganDonationLabel() })}
+          value={intl.formatMessage(
+            { id: getOrganDonationDescription() },
+            { limitations: isOrganDonorWithLimitations ? organLimitations?.join(', ') : '' }
+          )}
           loading={organDonationRes.loading && !organDonationRes.data}
           error={organDonationRes.error && !organDonationRes.data}
           noBorder
         />
       </InputRow>
     )}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c81f657 and 1f050bb.

📒 Files selected for processing (1)
  • apps/native/app/src/screens/health/health-overview.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`apps/**/*`: "Confirm that the code adheres to the following...

apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
  • apps/native/app/src/screens/health/health-overview.tsx
🔇 Additional comments (1)
apps/native/app/src/screens/health/health-overview.tsx (1)

553-554: LGTM! The condition now correctly handles error states.

The updated condition ensures that the organ donation status is only displayed when data is being loaded or is available, preventing misleading information during service errors.

Copy link
Member

@snaerth snaerth left a comment

Choose a reason for hiding this comment

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

LGTM

@thoreyjona thoreyjona added this pull request to the merge queue Feb 6, 2025
Merged via the queue into main with commit a64c5ea Feb 6, 2025
30 checks passed
@thoreyjona thoreyjona deleted the fix/error-if-organ-donation-service-is-down branch February 6, 2025 14:11
@coderabbitai coderabbitai bot mentioned this pull request Feb 19, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants