mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 19:03:15 +00:00
Split oversized API/mapper/UI modules and extract focused helpers so the exact head satisfies godfile and complexity ratchets without relaxing thresholds.
29 lines
1 KiB
TypeScript
29 lines
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 { formatApptTimeValue } from "@/domain/work-orders/utils/wizard-date-utils";
|
|
|
|
/** Mutates `payload` with `vendorId` and, when applicable, single-day appt date/time. */
|
|
export function assignWizardVendorApptFields(
|
|
payload: WorkOrderBoardCreatePayload,
|
|
draft: WorkOrderWizardDraft,
|
|
): void {
|
|
const vendorId = draft.vendorId.trim() ? Number(draft.vendorId) : NaN;
|
|
const hasVendor = Number.isFinite(vendorId);
|
|
|
|
if (hasVendor) {
|
|
payload.vendorId = vendorId;
|
|
}
|
|
|
|
const apptTime = formatApptTimeValue(draft.apptStart, draft.apptEnd);
|
|
const isRange = draft.schedMode === "range";
|
|
|
|
if (hasVendor && (draft.scheduledOn || apptTime) && !draft.scheduleWeekOnly && !isRange) {
|
|
if (draft.scheduledOn) {
|
|
payload.apptDate = draft.scheduledOn;
|
|
}
|
|
|
|
if (apptTime) {
|
|
payload.apptTime = apptTime;
|
|
}
|
|
}
|
|
}
|