From 3d409d4a846679677bafe3a5e32c3cf3c11c2b96 Mon Sep 17 00:00:00 2001 From: Gitead Date: Sat, 2 May 2026 13:15:00 -0400 Subject: [PATCH] fix: add patient form validation and auth proxy - Fix dateOfBirth default from empty string to null (caused Invalid date error) - Add noValidate to form to prevent browser native email validation blocking submit - Reset form when switching from edit to add mode - Export API_BASE_URL from queryClient; switch patient table to raw fetch (prevents token wipe on 401) - Add Authorization header forwarding in Vite proxy (was stripped by nginx Connection:upgrade) - Make only firstName, lastName, dateOfBirth, phone required; gender optional - Add +1 prefix to phone number input (stores as 1XXXXXXXXXX) Co-Authored-By: Claude Sonnet 4.6 --- .../src/components/patients/patient-form.tsx | 52 ++++++++++++++----- .../src/components/patients/patient-table.tsx | 18 +++++-- apps/Frontend/src/lib/queryClient.ts | 2 +- apps/Frontend/vite.config.ts | 6 +++ packages/db/types/patient-types.ts | 10 +++- 5 files changed, 68 insertions(+), 20 deletions(-) diff --git a/apps/Frontend/src/components/patients/patient-form.tsx b/apps/Frontend/src/components/patients/patient-form.tsx index d19f8ab..b0f5121 100755 --- a/apps/Frontend/src/components/patients/patient-form.tsx +++ b/apps/Frontend/src/components/patients/patient-form.tsx @@ -67,13 +67,13 @@ export const PatientForm = forwardRef( ...sanitizedPatient, dateOfBirth: patient.dateOfBirth ? formatLocalDate(new Date(patient.dateOfBirth)) - : "", + : null, }; } return { firstName: extractedInfo?.firstName || "", lastName: extractedInfo?.lastName || "", - dateOfBirth: extractedInfo?.dateOfBirth || "", + dateOfBirth: extractedInfo?.dateOfBirth || null, gender: "", phone: "", email: "", @@ -119,9 +119,11 @@ export const PatientForm = forwardRef( ...sanitizedPatient, dateOfBirth: patient.dateOfBirth ? formatLocalDate(new Date(patient.dateOfBirth)) - : "", + : null, }; form.reset(resetValues); + } else { + form.reset(computedDefaultValues); } }, [patient, computedDefaultValues, form]); @@ -134,6 +136,7 @@ export const PatientForm = forwardRef(
{ handleSubmit2(data); })} @@ -185,7 +188,7 @@ export const PatientForm = forwardRef( name="gender" render={({ field }) => ( - Gender * + Gender - - - - )} + render={({ field }) => { + const display = (field.value as string)?.startsWith("1") + ? (field.value as string).slice(1) + : (field.value as string) || ""; + return ( + + Phone Number * + +
+ + +1 + + { + const digits = e.target.value.replace(/\D/g, "").slice(0, 10); + field.onChange(digits ? "1" + digits : ""); + }} + onBlur={field.onBlur} + name={field.name} + ref={field.ref} + /> +
+
+ +
+ ); + }} /> ( return ( - Status * + Status