'use client'; import { useRef } from 'react'; import { useTranslations } from 'next-intl'; import { Button } from '@/components/ui/shared/Button'; import { Dropdown } from '@/components/ui/shared/Dropdown'; import type { TreatmentDetailDraft } from '@/types/treatment'; import { TREATMENT_TYPE_COLORS, treatmentTypeLabelKey } from '@/components/ui/treatment/treatmentTypeDisplay'; interface TreatmentDetailsEditorProps { details: TreatmentDetailDraft[]; activeDetailId: string; onActiveDetailChange: (id: string) => void; onDetailsChange: (details: TreatmentDetailDraft[]) => void; isDetailLocked: (detail: TreatmentDetailDraft) => boolean; disabled: boolean; canEdit: boolean; saveStatus: 'idle' | 'dirty' | 'saving' | 'saved' | 'error'; uploadBusy: boolean; onAddDetail: () => void; onPreview: () => void; onUploadFiles: (files: FileList | null) => void; } export function TreatmentDetailsEditor({ details, activeDetailId, onActiveDetailChange, onDetailsChange, isDetailLocked, disabled, canEdit, saveStatus, uploadBusy, onAddDetail, onPreview, onUploadFiles, }: TreatmentDetailsEditorProps) { const t = useTranslations('treatment'); const tCommon = useTranslations('common'); const attachmentInputRef = useRef(null); const activeDetail = details.find((d) => d.clientId === activeDetailId) ?? details[0]; if (!activeDetail) return null; const locked = isDetailLocked(activeDetail); const readOnly = disabled || locked; const treatmentTypeTextColor = TREATMENT_TYPE_COLORS[activeDetail.treatmentType]; return (

{t('detailsTitle')}

{t('detailsSubtitle')}

{details.map((d, idx) => ( ))}
{locked && (

{t('detailLockedInShipment')}

)}