mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 16:43:13 +00:00
27 lines
955 B
TypeScript
27 lines
955 B
TypeScript
/**
|
|
* SH-356: a Due Date can never be earlier than Schedule On.
|
|
*
|
|
* The floor is the concrete Schedule On day, the start of a date range, or — for a
|
|
* week-only schedule (SH-110) — the first day of the target week.
|
|
*/
|
|
export function resolveDueDateFloor(schedule: {
|
|
scheduledOn?: string | null;
|
|
targetWeek?: string | null;
|
|
}): string {
|
|
return schedule.scheduledOn?.trim() || schedule.targetWeek?.trim() || "";
|
|
}
|
|
|
|
export function isDueDateBeforeFloor(dueDate: string | null | undefined, floor: string): boolean {
|
|
return Boolean(dueDate && floor && dueDate < floor);
|
|
}
|
|
|
|
/**
|
|
* Patch fragment for a Schedule On change: clears an existing Due Date that the new
|
|
* schedule would leave in the past. Never bumps it to a guessed value.
|
|
*/
|
|
export function clearDueDateBeforeSchedule(
|
|
dueDate: string | null | undefined,
|
|
nextFloor: string,
|
|
): { dueDate?: string } {
|
|
return isDueDateBeforeFloor(dueDate, nextFloor) ? { dueDate: "" } : {};
|
|
}
|