-
Notifications
You must be signed in to change notification settings - Fork 61
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
Conversation
WalkthroughThe 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
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
Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🌐 Web search-backed reviews and chat
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
View your CI Pipeline Execution ↗ for commit 1f050bb.
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this 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
📒 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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:
Summary by CodeRabbit