From 64c485025bdbcc59145f47f1934e62c578e30a49 Mon Sep 17 00:00:00 2001 From: "arthur.bassi" Date: Tue, 11 Aug 2026 17:42:48 -0300 Subject: [PATCH] fix(work-orders): enforce single-service wizard create per SH-118 Use single service selection in the wizard and omit extraServices from board create. --- .../wizard-step-location-service-select.tsx | 24 +++-------- .../assign-wizard-service-poc-fields.ts | 43 +------------------ .../wizard-service-clears-vendor.test.tsx | 40 +++++++++++++++++ .../mappers/work-order-board-mapper.test.ts | 8 ++-- 4 files changed, 52 insertions(+), 63 deletions(-) diff --git a/src/app/(protected)/workorders/_components/wizard/wizard-step-location-service-select.tsx b/src/app/(protected)/workorders/_components/wizard/wizard-step-location-service-select.tsx index 71d6ace7..0acc1014 100644 --- a/src/app/(protected)/workorders/_components/wizard/wizard-step-location-service-select.tsx +++ b/src/app/(protected)/workorders/_components/wizard/wizard-step-location-service-select.tsx @@ -28,18 +28,14 @@ export function WizardStepLocationServiceSelect({ onUpdate, onPatch, }: WizardStepLocationServiceSelectProps) { - const svcSel = [draft.pm, ...draft.extraServices].filter((p, i, a) => !!p && a.indexOf(p) === i); - const clearVendorIfPrimaryChanged = (nextPm: string): Partial => nextPm !== draft.pm ? { vendorId: "", vendorName: "", techPhone: "" } : {}; - const toggleSvc = (p: string) => { - const next = svcSel.includes(p) ? svcSel.filter((x) => x !== p) : [...svcSel, p]; - const nextPm = next[0] ?? ""; + const selectSvc = (p: string) => { onPatch({ - pm: nextPm, - extraServices: next.slice(1), - ...clearVendorIfPrimaryChanged(nextPm), + pm: p, + extraServices: [], + ...clearVendorIfPrimaryChanged(p), }); }; @@ -63,13 +59,7 @@ export function WizardStepLocationServiceSelect({ ), }; })} - onPick={(p) => - onPatch({ - pm: p, - extraServices: draft.extraServices.filter((x) => x !== p), - ...clearVendorIfPrimaryChanged(p), - }) - } + onPick={selectSvc} /> {!svcOpen ? (