improvement: delete action added for unsent treatment details. some edit controls added to details and shipments.

This commit is contained in:
2026-07-16 22:45:37 +03:30
parent 334b7841ae
commit cf07b4d8a8
7 changed files with 82 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ interface TreatmentDetailsEditorProps {
saveStatus: 'idle' | 'dirty' | 'saving' | 'saved' | 'error';
uploadBusy: boolean;
onAddDetail: () => void;
onRemoveDetail: () => void;
onUploadFiles: (files: FileList | null) => void;
}
@@ -48,9 +49,11 @@ export function TreatmentDetailsEditor({
saveStatus,
uploadBusy,
onAddDetail,
onRemoveDetail,
onUploadFiles,
}: TreatmentDetailsEditorProps) {
const t = useTranslations('treatment');
const tCommon = useTranslations('common');
const attachmentInputRef = useRef<HTMLInputElement>(null);
const activeDetail = details.find((d) => d.clientId === activeDetailId) ?? details[0];
@@ -58,6 +61,7 @@ export function TreatmentDetailsEditor({
const locked = isDetailLocked(activeDetail);
const readOnly = disabled || locked;
const canRemoveDetail = canEdit && !disabled && !locked && details.length > 1;
const treatmentTypeTextColor = isDetailTypeSelected(activeDetail)
? treatmentTypeColor(
activeDetail.treatmentType,
@@ -206,6 +210,21 @@ export function TreatmentDetailsEditor({
</ul>
)}
</div>
{canRemoveDetail ? (
<div className="pt-1">
<Button
type="button"
variant="danger"
onClick={onRemoveDetail}
disabled={uploadBusy}
fullWidth
className="sm:w-auto"
>
{tCommon('delete')}
</Button>
</div>
) : null}
</div>
{canEdit && saveStatus !== 'idle' && (