'use client'; import { useTranslations } from 'next-intl'; 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'; interface CreatePatientModalProps { isOpen: boolean; formData: CreatePatientInput; onChange: (patch: Partial) => void; onSubmit: () => void; onClose: () => void; loading?: boolean; /** Inline panel on Patients page; centered dialog on Appointments. */ variant?: 'inline' | 'dialog'; } function CreatePatientFormFields({ formData, onChange, onSubmit, onClose, loading, showCancel, }: { formData: CreatePatientInput; onChange: (patch: Partial) => void; onSubmit: () => void; onClose: () => void; loading: boolean; showCancel: boolean; }) { const t = useTranslations('patients'); const tCommon = useTranslations('common'); return ( <>
onChange({ firstName: e.target.value })} /> onChange({ lastName: e.target.value })} /> onChange({ phone: e.target.value })} /> onChange({ email: e.target.value })} />
{showCancel && ( )}
); } export function CreatePatientModal({ isOpen, formData, onChange, onSubmit, onClose, loading = false, variant = 'inline', }: CreatePatientModalProps) { const t = useTranslations('patients'); if (!isOpen) { return null; } if (variant === 'dialog') { return (
{ if (e.target === e.currentTarget) { onClose(); } }} >
e.stopPropagation()} >

{t('dialogTitle')}

); } return (
); }