From ebc2e9a1e56eb3686d3a526034231d9d88baf0a7 Mon Sep 17 00:00:00 2001 From: Arthur Bassi <201806768+bassi-arthurr@users.noreply.github.com> Date: Mon, 10 Aug 2026 17:12:09 -0300 Subject: [PATCH 01/17] fix(work-orders): extract inline dialog state and enable Schedule On clear [recover] remove malicious eslint payload (was 552c2daf) --- .../table/build-inline-draft-create-input.ts | 7 +- .../list/table/cells/date-cell.tsx | 18 +++ .../list/table/cells/site-cell.tsx | 14 +- .../table/cells/site-dialog-poc-fields.tsx | 76 +++++++--- .../list/table/cells/site-dialog.tsx | 143 ++++++------------ .../list/table/cells/use-site-dialog-state.ts | 136 +++++++++++++++++ .../list/table/inline-create-field.tsx | 32 ++++ .../table/wo-table-inline-identity-cells.tsx | 82 ++++++++++ .../table/wo-table-inline-row-actions.tsx | 11 +- .../list/table/wo-table-inline-row-cells.tsx | 66 ++++---- .../list/table/wo-table-inline-row.tsx | 87 +++++++---- .../_hooks/use-work-orders-table-ui-state.ts | 8 +- .../mappers/assign-wizard-schedule-fields.ts | 4 +- .../utils/get-inline-create-missing.ts | 62 ++++++++ .../build-inline-draft-create-input.test.ts | 55 +++++++ .../mappers/work-order-board-mapper.test.ts | 15 ++ .../utils/get-inline-create-missing.test.ts | 82 ++++++++++ 17 files changed, 709 insertions(+), 189 deletions(-) create mode 100644 src/app/(protected)/workorders/_components/list/table/cells/use-site-dialog-state.ts create mode 100644 src/app/(protected)/workorders/_components/list/table/inline-create-field.tsx create mode 100644 src/app/(protected)/workorders/_components/list/table/wo-table-inline-identity-cells.tsx create mode 100644 src/domain/work-orders/utils/get-inline-create-missing.ts create mode 100644 src/test/app/(protected)/workorders/build-inline-draft-create-input.test.ts create mode 100644 src/test/domain/work-orders/utils/get-inline-create-missing.test.ts diff --git a/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts b/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts index 53c2f381..0edec077 100644 --- a/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts +++ b/src/app/(protected)/workorders/_components/list/table/build-inline-draft-create-input.ts @@ -12,12 +12,15 @@ export function buildInlineDraftCreateInput( const location = sites.find((s) => String(s.id) === String(draft.locationId)); const locationName = draft.location || draft.site || location?.name || ""; + const hasWeekTarget = Boolean(draft.targetWeek?.trim()); + const scheduleWeekOnly = draft.scheduleWeekOnly && (hasWeekTarget || Boolean(draft.scheduledOn)); + return { locationId: String(draft.locationId || ""), locationName, siteCode: location ? resolveSiteCode(location) : resolveSiteCode({ name: locationName }), woNumber: draft.woNumber, - type: draft.type, + type: draft.type || "PM", assigneeId: draft.dispatcherId, assigneeName: assignee?.name ?? "", scheduledOn: draft.scheduledOn, @@ -35,7 +38,7 @@ export function buildInlineDraftCreateInput( pocName: draft.pocName, pocPhone: draft.pocPhone, pocNotes: draft.pocNotes, - scheduleWeekOnly: draft.scheduleWeekOnly, + scheduleWeekOnly, targetWeek: draft.targetWeek || "", }; } diff --git a/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx b/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx index 417ffe22..6d78143e 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/date-cell.tsx @@ -15,6 +15,8 @@ type DateCellProps = { targetWeek?: string; onSaveWeek?: (weekStart: string) => void; defaultMode?: "week" | "date"; + /** When set, shows Clear in the popover so schedule can be removed (e.g. day-group → Unscheduled). */ + onClear?: () => void; }; export function DateCell({ @@ -26,6 +28,7 @@ export function DateCell({ targetWeek = "", onSaveWeek, defaultMode, + onClear, }: DateCellProps) { const [anchorEl, setAnchorEl] = useState(null); const [cellMode, setCellMode] = useState<"week" | "date">( @@ -132,6 +135,21 @@ export function DateCell({ }} /> )} + {Boolean(onClear) && ( +
+ +
+ )} ); diff --git a/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx b/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx index 939b4ce4..89a703f6 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/site-cell.tsx @@ -17,6 +17,8 @@ type SiteCellProps = { pocNotes?: string; sites: LocationOption[]; q?: string; + /** Inline create: editable POC + Site/POC required to confirm the modal. */ + createMode?: boolean; onSave: (patch: SitePatch) => void; }; @@ -31,6 +33,7 @@ export function SiteCell({ pocNotes, sites, q, + createMode = false, onSave, }: SiteCellProps) { const [open, setOpen] = useState(false); @@ -70,7 +73,15 @@ export function SiteCell({ )} ) : ( - — + + {createMode ? ( + <> + Site * + + ) : ( + "—" + )} + )} @@ -83,6 +94,7 @@ export function SiteCell({ pocPhone={pocPhone} pocNotes={pocNotes} sites={sites} + createMode={createMode} onSave={onSave} /> diff --git a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx index 145250c2..61ca8f78 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/site-dialog-poc-fields.tsx @@ -9,37 +9,77 @@ type SiteDialogPocFieldsProps = { pocName: string; pocPhone: string; pocNotes: string; + editable?: boolean; + showErrors?: boolean; + onPocNameChange?: (value: string) => void; + onPocPhoneChange?: (value: string) => void; + onPocNotesChange?: (value: string) => void; }; -export function SiteDialogPocFields({ pocName, pocPhone, pocNotes }: SiteDialogPocFieldsProps) { +export function SiteDialogPocFields({ + pocName, + pocPhone, + pocNotes, + editable = false, + showErrors = false, + onPocNameChange, + onPocPhoneChange, + onPocNotesChange, +}: SiteDialogPocFieldsProps) { + const nameMissing = showErrors && !pocName.trim(); + const phoneMissing = showErrors && !pocPhone.trim(); + return (
Point of Contact - Shown from site/work order records. Board edit saves site code only. + {editable + ? "Auto-filled from records — edit if outdated" + : "Shown from site/work order records. Board edit saves site code only."}
- - +
+ onPocNameChange?.(e.target.value)} + /> + + Contact name is required + +
+
+ onPocPhoneChange?.(e.target.value)} + /> + + Contact phone is required + +