mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-01 10:53:11 +00:00
fix(work-orders): send wizard status and clear POC notes on site change
Map draft.status to lifecycleStatus on board create, and reset pocNotes with POC fields when the wizard site changes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d44cda05d9
commit
c8a8522499
5 changed files with 33 additions and 2 deletions
|
|
@ -41,6 +41,7 @@ export function WizardStepLocationSiteSelect({
|
|||
siteCode: loc ? resolveSiteCode(loc) : "",
|
||||
pocName: "",
|
||||
pocPhone: "",
|
||||
pocNotes: "",
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -3,9 +3,16 @@ import type {
|
|||
WorkOrderTypeApi,
|
||||
} from "@/domain/work-orders/types/work-order-board";
|
||||
|
||||
import { WORK_ORDER_TYPE_API } from "@/domain/work-orders/types/work-order-board";
|
||||
import {
|
||||
LIFECYCLE_STATUS_API,
|
||||
WORK_ORDER_TYPE_API,
|
||||
} from "@/domain/work-orders/types/work-order-board";
|
||||
|
||||
import type { WOType, WorkOrderWizardDraft } from "@/domain/work-orders/types/work-order-wizard";
|
||||
import type {
|
||||
WizardWOStatus,
|
||||
WOType,
|
||||
WorkOrderWizardDraft,
|
||||
} from "@/domain/work-orders/types/work-order-wizard";
|
||||
|
||||
import { fmtDateRange } from "@/domain/work-orders/utils/wizard-date-utils";
|
||||
|
||||
|
|
@ -98,6 +105,10 @@ export function mapWizardDraftToBoardCreatePayload(
|
|||
siteCode,
|
||||
};
|
||||
|
||||
if (draft.status) {
|
||||
payload.lifecycleStatus = LIFECYCLE_STATUS_API[draft.status as WizardWOStatus];
|
||||
}
|
||||
|
||||
if (draft.woNumber.trim()) {
|
||||
payload.woNumber = draft.woNumber.trim();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ export const LIFECYCLE_STATUS_API_TO_FE: Record<number, WizardWOStatus | "Cancel
|
|||
export interface WorkOrderBoardCreatePayload {
|
||||
workOrderType: WorkOrderTypeApi;
|
||||
siteCode: string;
|
||||
/** Lifecycle status selected in the wizard; numeric board enum. */
|
||||
lifecycleStatus?: LifecycleStatusApi;
|
||||
woNumber?: string;
|
||||
assignTo?: string;
|
||||
dueDate?: string;
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ describe("workOrdersApi.createFromBoard", () => {
|
|||
expect(apiPost).toHaveBeenCalledWith(API_PATHS.workOrder.boardCreate, {
|
||||
workOrderType: 2,
|
||||
siteCode: "BK5",
|
||||
lifecycleStatus: 1,
|
||||
woNumber: "12345",
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,9 +55,25 @@ describe("mapWizardDraftToBoardCreatePayload", () => {
|
|||
workOrderType: 2,
|
||||
|
||||
siteCode: "BK5",
|
||||
|
||||
lifecycleStatus: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("maps wizard status to lifecycleStatus on create", () => {
|
||||
const payload = mapWizardDraftToBoardCreatePayload({
|
||||
...EMPTY_WIZARD_DRAFT,
|
||||
|
||||
type: "PM",
|
||||
|
||||
siteCode: "BK5",
|
||||
|
||||
status: "Scheduled",
|
||||
});
|
||||
|
||||
expect(payload.lifecycleStatus).toBe(3);
|
||||
});
|
||||
|
||||
it("maps full wizard payload with structured service and notes fields", () => {
|
||||
const payload = mapWizardDraftToBoardCreatePayload({
|
||||
...EMPTY_WIZARD_DRAFT,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue