diff --git a/frontend/src/app/(dashboard)/appointments/page.tsx b/frontend/src/app/(dashboard)/appointments/page.tsx index b40d35e..bf7734b 100644 --- a/frontend/src/app/(dashboard)/appointments/page.tsx +++ b/frontend/src/app/(dashboard)/appointments/page.tsx @@ -273,6 +273,7 @@ export default function AppointmentsPage() { if (!canEditPatients) { return; } + setPatientForm(EMPTY_PATIENT_FORM); setIsCreateOpen(true); }} /> @@ -322,18 +323,18 @@ export default function AppointmentsPage() { deleting={deletingAppointment} /> - {isCreateOpen && ( -
- setPatientForm((prev) => ({ ...prev, ...patch }))} - onSubmit={() => void handleCreatePatient()} - onClose={() => setIsCreateOpen(false)} - loading={savingPatient} - /> -
- )} + setPatientForm((prev) => ({ ...prev, ...patch }))} + onSubmit={() => void handleCreatePatient()} + onClose={() => { + setIsCreateOpen(false); + setPatientForm(EMPTY_PATIENT_FORM); + }} + loading={savingPatient} + /> ); diff --git a/frontend/src/app/(dashboard)/patients/page.tsx b/frontend/src/app/(dashboard)/patients/page.tsx index ae5ca16..75a3ccf 100644 --- a/frontend/src/app/(dashboard)/patients/page.tsx +++ b/frontend/src/app/(dashboard)/patients/page.tsx @@ -147,6 +147,7 @@ export default function PatientsPage() { onClick={() => { if (!canEditPatients) return; toast.clear(); + setPatientForm(EMPTY_PATIENT_FORM); setIsCreateOpen(true); }} title={!canEditPatients ? 'Read-only access for this organization.' : undefined} @@ -163,7 +164,10 @@ export default function PatientsPage() { formData={patientForm} onChange={(patch) => setPatientForm((prev) => ({ ...prev, ...patch }))} onSubmit={() => void handleCreatePatient()} - onClose={() => setIsCreateOpen(false)} + onClose={() => { + setIsCreateOpen(false); + setPatientForm(EMPTY_PATIENT_FORM); + }} loading={savingPatient} /> )} diff --git a/frontend/src/components/ui/appointments/AppointmentsPatientSearch.tsx b/frontend/src/components/ui/appointments/AppointmentsPatientSearch.tsx index 91aa24c..e0817fd 100644 --- a/frontend/src/components/ui/appointments/AppointmentsPatientSearch.tsx +++ b/frontend/src/components/ui/appointments/AppointmentsPatientSearch.tsx @@ -49,7 +49,7 @@ export function AppointmentsPatientSearch({ onClick={onAddPatient} title={!canAddPatient ? 'You do not have permission to add patients.' : undefined} > - + Add New Patient + New Patient )} diff --git a/frontend/src/components/ui/patient/CreatePatientModal.tsx b/frontend/src/components/ui/patient/CreatePatientModal.tsx index 0820cf9..2a52439 100644 --- a/frontend/src/components/ui/patient/CreatePatientModal.tsx +++ b/frontend/src/components/ui/patient/CreatePatientModal.tsx @@ -1,6 +1,7 @@ 'use client'; import { Button } from '@/components/ui/shared/Button'; +import { DialogCloseButton } from '@/components/ui/shared/DialogCloseButton'; import { Input } from '@/components/ui/shared/Input'; import { CreatePatientInput } from '@/types/patient'; @@ -11,22 +12,27 @@ interface CreatePatientModalProps { onSubmit: () => void; onClose: () => void; loading?: boolean; + /** Inline panel on Patients page; centered dialog on Appointments. */ + variant?: 'inline' | 'dialog'; } -export function CreatePatientModal({ - isOpen, +function CreatePatientFormFields({ formData, onChange, onSubmit, onClose, - loading = false, -}: CreatePatientModalProps) { - if (!isOpen) { - return null; - } - + loading, + showCancel, +}: { + formData: CreatePatientInput; + onChange: (patch: Partial) => void; + onSubmit: () => void; + onClose: () => void; + loading: boolean; + showCancel: boolean; +}) { return ( -
+ <>
Save Patient - + {showCancel && ( + + )}
+ + ); +} + +export function CreatePatientModal({ + isOpen, + formData, + onChange, + onSubmit, + onClose, + loading = false, + variant = 'inline', +}: CreatePatientModalProps) { + if (!isOpen) { + return null; + } + + if (variant === 'dialog') { + return ( +
{ + if (e.target === e.currentTarget) { + onClose(); + } + }} + > +
e.stopPropagation()} + > +
+

+ New patient +

+ +
+ + +
+
+ ); + } + + return ( +
+
); }