Skip to content

Add sex field, rare-group warning, and timeout fallback banner#2

Merged
SarmaHighOnCode merged 2 commits into
mainfrom
frontend-improvements
Jun 21, 2026
Merged

Add sex field, rare-group warning, and timeout fallback banner#2
SarmaHighOnCode merged 2 commits into
mainfrom
frontend-improvements

Conversation

@SarmaHighOnCode

Copy link
Copy Markdown
Owner

Summary

  • Donor form — optional sex selector (Male / Female) so the backend applies the correct donation cooldown (90 days for men, 120 for women). Passes sex to POST /donor/register; field is optional so existing flows still work.
  • Emergency trigger — saves bloodGroup, emergencyType, and rare_group to sessionStorage on success, keyed by request_id, so the results screen has context without an extra round-trip.
  • Results screen — two new warning banners:
    • Rare blood group (Rh-negative) — shown when rare_group is true, warns that compatible donors may be scarce.
    • Timeout fallback — shown when unconfirmed_fallback is true (no hospital confirmed after ~3 min), prompts family to call hospitals directly.
    • Mock timeout simulation toggle for demo purposes (only visible in mock mode).
  • api.ts — added rare_group? to EmergencyResponse and unconfirmed_fallback? to EmergencyStatusResponse; wired sex param through registerDonor.

What's NOT in this PR (kept from main)

PWA manifest, service worker, icons, and SW registration are kept as-is in main (this branch only touches frontend/src/).

Test plan

  • Build passes: npm run build (zero type errors) ✅
  • Donor registration: sex selector appears; omitting it still submits fine
  • Emergency flow: trigger emergency with Rh-negative group → rare-group banner appears on results screen
  • Timeout fallback banner: toggle "TIMEOUT: ON" in mock mode → banner appears after reset

… 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
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
goldenhour Ready Ready Preview, Comment Jun 21, 2026 4:14am

…fix stale closure

- Restore donorsAlerted setter (was frozen at 5); wire data.donors_alerted from
  updateStateFromPayload so the real API value is reflected in the UI
- Revert isMockMode default from opt-out (!== 'false') back to opt-in (=== 'true')
  so fresh production visitors hit the real API, not the mock simulation
- Add useRef guard to the localStorage write-back effect so the initial default
  is never baked into storage for users who never explicitly toggled mock mode
- Add mockTimeoutSimulation to the polling effect dependency array so the TIMEOUT
  toggle takes effect immediately (previously the interval held a stale closure)
- Restore isLoading conditional on the donors-alerted label (shows 'Locating
  donors nearby...' during the skeleton phase instead of the stale count)
@SarmaHighOnCode SarmaHighOnCode merged commit 1fd5736 into main Jun 21, 2026
@SarmaHighOnCode SarmaHighOnCode deleted the frontend-improvements branch June 21, 2026 04:14
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.

1 participant