'use client'; import { useTranslations } from 'next-intl'; import { Button } from '@/components/ui/shared/Button'; import type { PastTreatment } from '@/types/treatment'; const TREATMENT_TYPE_KEYS = { consultation: 'typeConsultation', filling: 'typeFilling', endo: 'typeEndo', visit: 'typeVisit', hygiene: 'typeHygiene', } as const; interface TreatmentPreviewCardProps { draft: PastTreatment | null; disabled?: boolean; onPreview: () => void; } export function TreatmentPreviewCard({ draft, disabled, onPreview }: TreatmentPreviewCardProps) { const t = useTranslations('treatment'); const attachmentCount = draft ? draft.details.reduce((n, c) => n + (c.attachmentMetas?.length ?? 0), 0) : 0; return (

{t('previewTitle')}

{!draft ? (

{t('selectAppointment')}

) : (

{draft.title}

{draft.status}

{t('caseCount', { n: draft.details.length })} ยท{' '} {t('attachmentCount', { n: attachmentCount })}

{draft.details.slice(0, 2).map((c, idx) => { const typeKey = TREATMENT_TYPE_KEYS[c.treatmentType as keyof typeof TREATMENT_TYPE_KEYS]; const typeLabel = typeKey ? t(typeKey) : c.treatmentType; return (
{t('caseSummary', { n: idx + 1, type: typeLabel })} {c.teeth.length > 0 && ( {t('teethPrefix')} {[...c.teeth].sort().join(', ')} )}
); })} {draft.details.length > 2 && (

{t('moreCases', { n: draft.details.length - 2 })}

)}
)}
); }