mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-01 00:23:12 +00:00
Allow empty Appt Time in wizard, table, and slide-over without blocking create or complete. Omit appointment fields without vendorId so create does not hit DispatchRequired.
33 lines
778 B
TypeScript
33 lines
778 B
TypeScript
import {
|
|
calcDuration,
|
|
formatApptTimeValue,
|
|
parseApptTime,
|
|
} from "@/domain/work-orders/utils/wizard-date-utils";
|
|
|
|
export function apptTimePopoverHint(start: string, end: string): string {
|
|
if (start && end) {
|
|
const duration = calcDuration(start, end);
|
|
return duration ? `Duration: ${duration}` : "—";
|
|
}
|
|
if (start) {
|
|
return "Pick end (optional)";
|
|
}
|
|
return "Pick a start time";
|
|
}
|
|
|
|
export function commitApptTimeSelection(
|
|
start: string,
|
|
end: string,
|
|
apptTime: string,
|
|
onSave: (value: string) => void,
|
|
): void {
|
|
if (start) {
|
|
onSave(formatApptTimeValue(start, end));
|
|
return;
|
|
}
|
|
const parsed = parseApptTime(apptTime);
|
|
const isRawUnparsed = Boolean(apptTime.trim()) && !parsed.start;
|
|
if (!isRawUnparsed) {
|
|
onSave("");
|
|
}
|
|
}
|