fix(ui): guard delete on paid invoices / ordered-or-locked offers; add guarded delete to issued orders

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-09 16:36:32 +02:00
parent 39565767ef
commit 20177e8f87
3 changed files with 86 additions and 19 deletions

View File

@@ -663,6 +663,11 @@ export default function OfferDetail() {
const isLockedByOther = !!lockedBy;
const readOnly = isInvalidated || isLockedByOther || isCompleted;
const canInvalidate = isEdit && !isInvalidated && !isCompleted && !orderInfo;
// An offer is deletable only when it has NOT spawned an order (orderInfo —
// deleting would orphan the linked order), is NOT invalidated, and is NOT
// locked by another user. (Backend rejection of deleting an ordered offer is
// a separate hardening, out of scope here.)
const canDelete = isEdit && !orderInfo && !isInvalidated && !isLockedByOther;
// Sync offer detail data to form state on first load (edit mode)
const formInitializedRef = useRef(false);
@@ -1190,7 +1195,7 @@ export default function OfferDetail() {
{saving ? "Ukládání..." : "Uložit"}
</Button>
)}
{isEdit && hasPermission("offers.delete") && (
{canDelete && hasPermission("offers.delete") && (
<Button
onClick={() => setDeleteConfirm(true)}
variant="outlined"