2026-05-19 23:43:43 +03:30
|
|
|
'use client';
|
|
|
|
|
|
2026-06-20 14:51:43 +03:30
|
|
|
import { useTranslations } from 'next-intl';
|
2026-05-19 23:43:43 +03:30
|
|
|
import { Button } from '@/components/ui/shared/Button';
|
2026-06-28 21:45:33 +03:30
|
|
|
import { TreatmentDetailSummaryRow } from '@/components/ui/treatment/TreatmentDetailSummaryRow';
|
|
|
|
|
import type { LinkedOrganizationOption, PastTreatment } from '@/types/treatment';
|
2026-07-06 20:40:19 +03:30
|
|
|
import type { TreatmentCatalogEntry } from '@/types/treatment-catalog';
|
2026-06-20 14:51:43 +03:30
|
|
|
|
2026-05-19 23:43:43 +03:30
|
|
|
interface TreatmentPreviewCardProps {
|
2026-06-28 21:45:33 +03:30
|
|
|
treatment: PastTreatment | null;
|
|
|
|
|
labDependentCodes: Set<string>;
|
2026-07-06 20:40:19 +03:30
|
|
|
treatmentCatalog: TreatmentCatalogEntry[];
|
2026-06-28 21:45:33 +03:30
|
|
|
orgs?: LinkedOrganizationOption[];
|
|
|
|
|
openDisabled?: boolean;
|
|
|
|
|
onOpen: () => void;
|
2026-05-19 23:43:43 +03:30
|
|
|
}
|
|
|
|
|
|
2026-06-28 21:45:33 +03:30
|
|
|
export function TreatmentPreviewCard({
|
|
|
|
|
treatment,
|
|
|
|
|
labDependentCodes,
|
2026-07-06 20:40:19 +03:30
|
|
|
treatmentCatalog,
|
2026-06-28 21:45:33 +03:30
|
|
|
orgs,
|
|
|
|
|
openDisabled = false,
|
|
|
|
|
onOpen,
|
|
|
|
|
}: TreatmentPreviewCardProps) {
|
2026-06-20 14:51:43 +03:30
|
|
|
const t = useTranslations('treatment');
|
|
|
|
|
|
2026-05-19 23:43:43 +03:30
|
|
|
return (
|
|
|
|
|
<div className="surface-card p-4 space-y-3">
|
|
|
|
|
<div className="flex items-center justify-between gap-2">
|
2026-06-20 14:51:43 +03:30
|
|
|
<h3 className="text-sm font-semibold text-text-primary">{t('previewTitle')}</h3>
|
2026-06-28 21:45:33 +03:30
|
|
|
<Button type="button" variant="primary" disabled={openDisabled || !treatment} onClick={onOpen}>
|
|
|
|
|
{t('openTreatment')}
|
2026-05-19 23:43:43 +03:30
|
|
|
</Button>
|
|
|
|
|
</div>
|
2026-06-28 21:45:33 +03:30
|
|
|
{!treatment ? (
|
2026-06-20 14:51:43 +03:30
|
|
|
<p className="text-sm text-text-muted">{t('selectAppointment')}</p>
|
2026-05-19 23:43:43 +03:30
|
|
|
) : (
|
|
|
|
|
<div className="border border-border/70 rounded-[var(--radius-md)] p-3 bg-background-secondary/40 space-y-2">
|
|
|
|
|
<div className="flex items-start justify-between gap-2">
|
2026-06-28 21:45:33 +03:30
|
|
|
<p className="text-sm font-medium text-text-primary">{treatment.title}</p>
|
|
|
|
|
<time
|
|
|
|
|
className="text-xs text-text-muted tabular-nums shrink-0"
|
|
|
|
|
dateTime={treatment.treatmentAt}
|
|
|
|
|
>
|
|
|
|
|
{new Date(treatment.treatmentAt).toLocaleDateString()}
|
|
|
|
|
</time>
|
2026-05-19 23:43:43 +03:30
|
|
|
</div>
|
2026-06-28 21:45:33 +03:30
|
|
|
<div className="space-y-2 max-h-[min(280px,40vh)] overflow-y-auto pr-1">
|
|
|
|
|
{treatment.details.length === 0 ? (
|
|
|
|
|
<p className="text-xs text-text-muted">{t('noDetails')}</p>
|
|
|
|
|
) : (
|
|
|
|
|
treatment.details.map((detail, idx) => (
|
|
|
|
|
<TreatmentDetailSummaryRow
|
|
|
|
|
key={detail.clientId ?? detail.id}
|
|
|
|
|
detail={detail}
|
|
|
|
|
detailNumber={idx + 1}
|
|
|
|
|
labDependentCodes={labDependentCodes}
|
2026-07-06 20:40:19 +03:30
|
|
|
treatmentCatalog={treatmentCatalog}
|
2026-06-28 21:45:33 +03:30
|
|
|
orgs={orgs}
|
|
|
|
|
compact
|
|
|
|
|
/>
|
|
|
|
|
))
|
2026-05-19 23:43:43 +03:30
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|