-
Notifications
You must be signed in to change notification settings - Fork 539
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: showing "-" in the emergency contact person field to represent the field is null #10323
Fix: showing "-" in the emergency contact person field to represent the field is null #10323
Conversation
WalkthroughThe pull request involves a modification to the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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: 1
🧹 Nitpick comments (1)
src/components/Patient/PatientDetailsTab/Demography.tsx (1)
Line range hint
65-95
: Consider enhancing the EmergencyContact component.The component could benefit from several improvements:
- Add proper ARIA labels for accessibility
- Make props type more explicit
- Consider adding similar interactive features for the name as provided for the number
Here's a suggested implementation:
- const EmergencyContact = (props: { number?: string; name?: string }) => ( + interface EmergencyContactProps { + number?: string; + name?: string; + } + + const EmergencyContact = ({ number, name }: EmergencyContactProps) => ( <div className="sm:col-span-2"> - <div className="mr-6 flex flex-col items-start justify-between rounded-md border border-orange-300 bg-orange-50 p-4 sm:flex-row"> + <div + className="mr-6 flex flex-col items-start justify-between rounded-md border border-orange-300 bg-orange-50 p-4 sm:flex-row" + role="region" + aria-label={t("emergency_contact_section")} + > <div className="flex-1"> - <div className="text-sm font-normal leading-5 text-gray-600"> + <div className="text-sm font-normal leading-5 text-gray-600" aria-label={t("emergency_contact_number_label")}> {t("emergency_contact")} </div> <div className="mt-1 text-sm leading-5 text-secondary-900"> <div> <a href={`tel:${props.number}`} className="text-sm font-medium text-black hover:text-secondary-500" + aria-label={t("call_emergency_contact", { number: props.number })} > - {props.number || "-"} + {number || "-"} </a> </div> - {props.number && ( + {number && ( <div> <a - href={`https://wa.me/${props.number?.replace(/\D+/g, "")}`} + href={`https://wa.me/${number.replace(/\D+/g, "")}`} target="_blank" className="text-sm font-normal text-sky-600 hover:text-sky-300" rel="noreferrer" + aria-label={t("whatsapp_emergency_contact", { number })} > <CareIcon icon="l-whatsapp" /> {t("chat_on_whatsapp")} </a> </div> )} </div> </div> <div className="ml-0 mt-4 flex-1 sm:ml-4 sm:mt-0"> - <div className="text-sm font-normal leading-5 text-gray-600"> + <div className="text-sm font-normal leading-5 text-gray-600" aria-label={t("emergency_contact_name_label")}> {t("emergency_contact_person_name")} </div> <div className="mt-1 text-sm font-semibold leading-5 text-gray-900"> - - + {name || "-"} </div> </div> </div> </div> );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/Patient/PatientDetailsTab/Demography.tsx
(1 hunks)
🔇 Additional comments (1)
src/components/Patient/PatientDetailsTab/Demography.tsx (1)
Line range hint
174-178
: Fix incorrect prop passed to EmergencyContact component.The component is being passed
patientData.name
which is the patient's name, not the emergency contact person's name. This is logically incorrect as it displays the patient's own name as their emergency contact.Verify if there's a dedicated field for emergency contact person's name in the patient data model and update the prop accordingly:
<EmergencyContact key="emergency-contact" number={patientData.emergency_phone_number} - name={patientData.name} + name={patientData.emergency_contact_name} />,Let's verify the patient data model:
@@ -89,7 +89,7 @@ export const Demography = (props: PatientProps) => { | |||
{t("emergency_contact_person_name")} | |||
</div> | |||
<div className="mt-1 text-sm font-semibold leading-5 text-gray-900"> | |||
{props.name || "-"} | |||
- |
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.
The change contradicts the PR objective.
The PR objective is to show "-" when the emergency contact person field is null. However, the current change always shows "-" even when a valid name is provided through props.name
.
Apply this diff to fix the logic:
- -
+ {props.name || "-"}
This will:
- Show the name when it's provided
- Show "-" only when the name is null/undefined
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- | |
{props.name || "-"} |
@Prakhar29Sharma 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! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit