mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 12:03:12 +00:00
* feat(work-orders): board wizard create with service notes Co-authored-by: Cursor <cursoragent@cursor.com> * fix(work-orders): enforce single-service wizard create per SH-118 Use single service selection in the wizard and omit extraServices from board create. * refactor(work-orders): extract wizard controller for maintainability gate Move duplicate-WO wiring and lookup hooks out of NewWoWizard so the changed-file function line cap passes after merging dev. --------- Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import type { WorkOrderBoardCreatePayload } from "@/domain/work-orders/types/work-order-board";
|
|
import type { WorkOrderWizardDraft } from "@/domain/work-orders/types/work-order-wizard";
|
|
import { mondayOf } from "@/domain/work-orders/utils/wizard-date-utils";
|
|
|
|
/**
|
|
* Mutates `payload` with `dueDate` and schedule fields.
|
|
* Range mode lands on the board using the range start as `scheduledDate`
|
|
* (prototype `hasScheduleDate`: a range start qualifies as scheduled).
|
|
*/
|
|
export function assignWizardScheduleFields(
|
|
payload: WorkOrderBoardCreatePayload,
|
|
draft: WorkOrderWizardDraft,
|
|
): void {
|
|
if (draft.dueDate) {
|
|
payload.dueDate = draft.dueDate;
|
|
}
|
|
|
|
const isRange = draft.schedMode === "range";
|
|
|
|
if (!isRange && draft.scheduleWeekOnly) {
|
|
const week = draft.targetWeek?.trim() || (draft.scheduledOn ? mondayOf(draft.scheduledOn) : "");
|
|
|
|
// Only emit week-mode flags when a concrete week exists (SH-109: undated create).
|
|
if (week) {
|
|
payload.scheduleWeekOnly = true;
|
|
payload.targetWeek = week;
|
|
}
|
|
} else if (draft.scheduledOn && (isRange || !draft.scheduleWeekOnly)) {
|
|
payload.scheduledDate = draft.scheduledOn;
|
|
}
|
|
}
|