bugfix/demo-bugs-fixed #19
@@ -273,6 +273,7 @@ export default function AppointmentsPage() {
|
|||||||
if (!canEditPatients) {
|
if (!canEditPatients) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setPatientForm(EMPTY_PATIENT_FORM);
|
||||||
setIsCreateOpen(true);
|
setIsCreateOpen(true);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -322,18 +323,18 @@ export default function AppointmentsPage() {
|
|||||||
deleting={deletingAppointment}
|
deleting={deletingAppointment}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{isCreateOpen && (
|
|
||||||
<div className="fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/55">
|
|
||||||
<CreatePatientModal
|
<CreatePatientModal
|
||||||
|
variant="dialog"
|
||||||
isOpen={isCreateOpen}
|
isOpen={isCreateOpen}
|
||||||
formData={patientForm}
|
formData={patientForm}
|
||||||
onChange={(patch) => setPatientForm((prev) => ({ ...prev, ...patch }))}
|
onChange={(patch) => setPatientForm((prev) => ({ ...prev, ...patch }))}
|
||||||
onSubmit={() => void handleCreatePatient()}
|
onSubmit={() => void handleCreatePatient()}
|
||||||
onClose={() => setIsCreateOpen(false)}
|
onClose={() => {
|
||||||
|
setIsCreateOpen(false);
|
||||||
|
setPatientForm(EMPTY_PATIENT_FORM);
|
||||||
|
}}
|
||||||
loading={savingPatient}
|
loading={savingPatient}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ export default function PatientsPage() {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!canEditPatients) return;
|
if (!canEditPatients) return;
|
||||||
toast.clear();
|
toast.clear();
|
||||||
|
setPatientForm(EMPTY_PATIENT_FORM);
|
||||||
setIsCreateOpen(true);
|
setIsCreateOpen(true);
|
||||||
}}
|
}}
|
||||||
title={!canEditPatients ? 'Read-only access for this organization.' : undefined}
|
title={!canEditPatients ? 'Read-only access for this organization.' : undefined}
|
||||||
@@ -163,7 +164,10 @@ export default function PatientsPage() {
|
|||||||
formData={patientForm}
|
formData={patientForm}
|
||||||
onChange={(patch) => setPatientForm((prev) => ({ ...prev, ...patch }))}
|
onChange={(patch) => setPatientForm((prev) => ({ ...prev, ...patch }))}
|
||||||
onSubmit={() => void handleCreatePatient()}
|
onSubmit={() => void handleCreatePatient()}
|
||||||
onClose={() => setIsCreateOpen(false)}
|
onClose={() => {
|
||||||
|
setIsCreateOpen(false);
|
||||||
|
setPatientForm(EMPTY_PATIENT_FORM);
|
||||||
|
}}
|
||||||
loading={savingPatient}
|
loading={savingPatient}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export function AppointmentsPatientSearch({
|
|||||||
onClick={onAddPatient}
|
onClick={onAddPatient}
|
||||||
title={!canAddPatient ? 'You do not have permission to add patients.' : undefined}
|
title={!canAddPatient ? 'You do not have permission to add patients.' : undefined}
|
||||||
>
|
>
|
||||||
+ Add New Patient
|
New Patient
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Button } from '@/components/ui/shared/Button';
|
import { Button } from '@/components/ui/shared/Button';
|
||||||
|
import { DialogCloseButton } from '@/components/ui/shared/DialogCloseButton';
|
||||||
import { Input } from '@/components/ui/shared/Input';
|
import { Input } from '@/components/ui/shared/Input';
|
||||||
import { CreatePatientInput } from '@/types/patient';
|
import { CreatePatientInput } from '@/types/patient';
|
||||||
|
|
||||||
@@ -11,22 +12,27 @@ interface CreatePatientModalProps {
|
|||||||
onSubmit: () => void;
|
onSubmit: () => void;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
|
/** Inline panel on Patients page; centered dialog on Appointments. */
|
||||||
|
variant?: 'inline' | 'dialog';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreatePatientModal({
|
function CreatePatientFormFields({
|
||||||
isOpen,
|
|
||||||
formData,
|
formData,
|
||||||
onChange,
|
onChange,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onClose,
|
onClose,
|
||||||
loading = false,
|
loading,
|
||||||
}: CreatePatientModalProps) {
|
showCancel,
|
||||||
if (!isOpen) {
|
}: {
|
||||||
return null;
|
formData: CreatePatientInput;
|
||||||
}
|
onChange: (patch: Partial<CreatePatientInput>) => void;
|
||||||
|
onSubmit: () => void;
|
||||||
|
onClose: () => void;
|
||||||
|
loading: boolean;
|
||||||
|
showCancel: boolean;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="surface-card p-4 space-y-3">
|
<>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||||
<Input
|
<Input
|
||||||
label="First name"
|
label="First name"
|
||||||
@@ -60,10 +66,80 @@ export function CreatePatientModal({
|
|||||||
>
|
>
|
||||||
Save Patient
|
Save Patient
|
||||||
</Button>
|
</Button>
|
||||||
|
{showCancel && (
|
||||||
<Button variant="ghost" onClick={onClose}>
|
<Button variant="ghost" onClick={onClose}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CreatePatientModal({
|
||||||
|
isOpen,
|
||||||
|
formData,
|
||||||
|
onChange,
|
||||||
|
onSubmit,
|
||||||
|
onClose,
|
||||||
|
loading = false,
|
||||||
|
variant = 'inline',
|
||||||
|
}: CreatePatientModalProps) {
|
||||||
|
if (!isOpen) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variant === 'dialog') {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/55"
|
||||||
|
role="presentation"
|
||||||
|
onMouseDown={(e) => {
|
||||||
|
if (e.target === e.currentTarget) {
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="surface-card w-full max-w-[min(56rem,calc(100vw-17rem))] p-5 space-y-4 shadow-xl"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="create-patient-dialog-title"
|
||||||
|
onMouseDown={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
<div className="flex items-start justify-between gap-2">
|
||||||
|
<h2
|
||||||
|
id="create-patient-dialog-title"
|
||||||
|
className="text-lg font-semibold text-text-primary pr-2"
|
||||||
|
>
|
||||||
|
New patient
|
||||||
|
</h2>
|
||||||
|
<DialogCloseButton onClick={onClose} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CreatePatientFormFields
|
||||||
|
formData={formData}
|
||||||
|
onChange={onChange}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
onClose={onClose}
|
||||||
|
loading={loading}
|
||||||
|
showCancel={false}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="surface-card p-4 space-y-3">
|
||||||
|
<CreatePatientFormFields
|
||||||
|
formData={formData}
|
||||||
|
onChange={onChange}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
onClose={onClose}
|
||||||
|
loading={loading}
|
||||||
|
showCancel
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user