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 <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,15 @@ export const insertPatientSchema = (
|
||||
createdAt: true,
|
||||
})
|
||||
.extend({
|
||||
insuranceId: insuranceIdSchema, // enforce numeric insuranceId
|
||||
firstName: z.string().min(1, "First name is required"),
|
||||
lastName: z.string().min(1, "Last name is required"),
|
||||
dateOfBirth: z.preprocess(
|
||||
(val) => (val === null || val === undefined || val === "" ? undefined : val),
|
||||
z.coerce.date({ required_error: "Date of birth is required" })
|
||||
),
|
||||
gender: z.string().optional().nullable(),
|
||||
phone: z.string().min(1, "Phone number is required"),
|
||||
insuranceId: insuranceIdSchema,
|
||||
});
|
||||
|
||||
export type InsertPatient = z.infer<typeof insertPatientSchema>;
|
||||
|
||||
Reference in New Issue
Block a user