From fef7918f6bedda2a28e976f4982ab28dee3c767b Mon Sep 17 00:00:00 2001 From: Arthur Bassi Date: Wed, 22 Jul 2026 10:18:27 -0300 Subject: [PATCH] fix(work-orders): allow read-only open for canceled board rows --- .../list/table/wo-table-row-actions.tsx | 4 +- .../_components/list/table/wo-table-row.tsx | 122 ++++++++++++------ 2 files changed, 83 insertions(+), 43 deletions(-) diff --git a/src/app/(protected)/workorders/_components/list/table/wo-table-row-actions.tsx b/src/app/(protected)/workorders/_components/list/table/wo-table-row-actions.tsx index c6ceaf10..2ec9da42 100644 --- a/src/app/(protected)/workorders/_components/list/table/wo-table-row-actions.tsx +++ b/src/app/(protected)/workorders/_components/list/table/wo-table-row-actions.tsx @@ -3,7 +3,7 @@ import { Eye, Pencil } from "lucide-react"; type WoTableRowActionsProps = { onView: () => void; - onEdit: () => void; + onEdit?: () => void; }; export function WoTableRowActions({ onView, onEdit }: WoTableRowActionsProps) { @@ -61,7 +61,7 @@ export function WoTableRowActions({ onView, onEdit }: WoTableRowActionsProps) {
{mk(Eye, "View details", onView, "#e6f4fb", "var(--primary)")} - {mk(Pencil, "Edit", onEdit, "#e6f4fb", "var(--primary)")} + {onEdit ? mk(Pencil, "Edit", onEdit, "#e6f4fb", "var(--primary)") : null}
); } diff --git a/src/app/(protected)/workorders/_components/list/table/wo-table-row.tsx b/src/app/(protected)/workorders/_components/list/table/wo-table-row.tsx index f3210b61..b20e4e60 100644 --- a/src/app/(protected)/workorders/_components/list/table/wo-table-row.tsx +++ b/src/app/(protected)/workorders/_components/list/table/wo-table-row.tsx @@ -85,23 +85,37 @@ export function WoTableRow({ } const patchAndMaybeAuto = (patch: Partial) => { + if (isCanceled) return; const merged = { ...row, ...patch }; const auto = maybeAutoSchedulePatch(merged); handlers.onPatch(row.id, { ...patch, ...auto }); }; + const patchRow = (patch: Partial) => { + if (isCanceled) return; + handlers.onPatch(row.id, patch); + }; + + /** Block mutation controls on canceled rows while keeping row/View clickable. */ + const mutationCellStyle = isCanceled ? ({ pointerEvents: "none" } as const) : undefined; + return ( handlers.onRowClick(row)} - onDragStart={() => handlers.onDragStart(row.id)} + onDragStart={() => { + if (isCanceled) return; + handlers.onDragStart(row.id); + }} onDragOver={(e) => { + if (isCanceled) return; e.preventDefault(); handlers.onDragOver(row.id); }} onDrop={(e) => { + if (isCanceled) return; e.preventDefault(); handlers.onDrop(); }} @@ -112,7 +126,6 @@ export function WoTableRow({ borderBottom: "1px solid var(--border)", borderTop: isDropTarget ? "2px solid var(--color-primary)" : undefined, opacity: isCanceled ? 0.45 : isDragging ? 0.4 : 1, - pointerEvents: isCanceled ? "none" : undefined, background: isFlashing || isSelected ? "var(--color-primary-tint)" : "var(--card)", outline: isFlashing ? "2px solid var(--color-primary)" : "none", outlineOffset: isFlashing ? "-2px" : undefined, @@ -131,23 +144,34 @@ export function WoTableRow({ }} > e.stopPropagation()} > - e.stopPropagation()}> - handlers.setFlag(row.id, c)} /> + e.stopPropagation()} + > + handlers.setFlag(row.id, c)} + /> - e.stopPropagation()}> + e.stopPropagation()} + > - handlers.onPatch(row.id, { + patchRow({ site: p.site, location: p.location, locationId: p.locationId, @@ -169,7 +193,7 @@ export function WoTableRow({ } /> - + handlers.onPatch(row.id, { woNumber: v })} + onSave={(v) => patchRow({ woNumber: v })} onDuplicateFound={handlers.onDuplicateFound} /> - e.stopPropagation()}> - handlers.onPatch(row.id, { type: t })} - /> + e.stopPropagation()} + > + patchRow({ type: t })} /> - e.stopPropagation()}> + e.stopPropagation()} + > patchAndMaybeAuto({ dispatcherId: id, dispatcherName: name })} /> - e.stopPropagation()}> + e.stopPropagation()} + > - e.stopPropagation()}> - handlers.onPatch(row.id, { dueDate: date })} - /> + e.stopPropagation()} + > + patchRow({ dueDate: date })} /> - e.stopPropagation()}> - handlers.onPatch(row.id, { pm })} - /> + e.stopPropagation()} + > + patchRow({ pm })} /> - e.stopPropagation()}> + e.stopPropagation()} + > - handlers.onPatch(row.id, { + patchRow({ company: p.company, tech: p.tech, techPhone: p.techPhone, @@ -246,16 +281,21 @@ export function WoTableRow({ } /> - e.stopPropagation()}> - handlers.onPatch(row.id, { apptTime: v })} - /> + e.stopPropagation()} + > + patchRow({ apptTime: v })} /> - e.stopPropagation()}> + e.stopPropagation()} + > handlers.onPatch(row.id, { status })} + onChangeStatus={(status) => patchRow({ status })} onOpenSlideOver={() => handlers.onOpenSlideOver(row)} onPastDueAttempt={() => handlers.onPastDueAttempt?.(row.id)} /> @@ -272,7 +312,7 @@ export function WoTableRow({ e.stopPropagation()}> handlers.onView(row)} - onEdit={() => handlers.onEdit(row)} + onEdit={isCanceled ? undefined : () => handlers.onEdit(row)} />