mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 17:53:12 +00:00
34 lines
778 B
TypeScript
34 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("");
|
||
|
|
}
|
||
|
|
}
|