From adbf11314ce28f3c5b7e7ec6a113293879b12889 Mon Sep 17 00:00:00 2001 From: Prajnadeep Sarma Date: Sun, 21 Jun 2026 09:35:32 +0530 Subject: [PATCH 1/2] Add sex field to donor form, rare-group warning, and timeout fallback banner - DonorRegistration: add optional sex selector (M/F) and pass it to /donor/register so the backend can apply the correct donation cooldown (90d male, 120d female) - PatientIntakeView: save blood group and rare_group flag to sessionStorage on trigger so the results screen can display context without an extra API round-trip - PatientResultsView: read session cache to show rare blood group warning banner; surface unconfirmed_fallback banner when no hospital has responded after timeout; add mock timeout simulation toggle for demo purposes - api.ts: add rare_group? to EmergencyResponse and unconfirmed_fallback? to EmergencyStatusResponse; wire sex param through registerDonor call --- frontend/src/components/DonorRegistration.tsx | 18 ++- frontend/src/components/PatientIntakeView.tsx | 5 + .../src/components/PatientResultsView.tsx | 105 +++++++++++++++--- frontend/src/lib/api.ts | 6 +- 4 files changed, 119 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/DonorRegistration.tsx b/frontend/src/components/DonorRegistration.tsx index f1c7567..e0ad75e 100644 --- a/frontend/src/components/DonorRegistration.tsx +++ b/frontend/src/components/DonorRegistration.tsx @@ -15,6 +15,7 @@ export default function DonorRegistration() { const [phone, setPhone] = useState(''); const [bloodGroup, setBloodGroup] = useState(''); const [lastDonated, setLastDonated] = useState(''); + const [sex, setSex] = useState<'male' | 'female' | ''>(''); // Geolocation State const [locating, setLocating] = useState(false); @@ -91,7 +92,8 @@ export default function DonorRegistration() { bloodGroup, coords?.lat ?? null, coords?.lng ?? null, - lastDonated || null + lastDonated || null, + sex || null ); if (data && data.ok) { @@ -126,6 +128,12 @@ export default function DonorRegistration() { { value: 'AB-', label: 'AB-' } ]; + const sexOptions = [ + { value: '', label: '-- Select Sex (Optional) --' }, + { value: 'male', label: 'Male (90 days cooldown)' }, + { value: 'female', label: 'Female (120 days cooldown)' } + ]; + // Disable check: Name, Phone, and Blood Group must be populated const isButtonDisabled = !name.trim() || !phone.trim() || !bloodGroup; @@ -199,6 +207,14 @@ export default function DonorRegistration() { aria-required="true" /> + {/* Sex Selector */} +