improvement: delete action added for unsent treatment details. some edit controls added to details and shipments.
This commit is contained in:
@@ -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' && (
|
||||
|
||||
Reference in New Issue
Block a user