Files
calendar/packages/features/bookings/lib/reschedule/isWithinMinimumRescheduleNotice.ts
sean-brydonandGitHub b46fb82695 feat: minium reschedule notice on events (#25575)
* wip

* add i18n and essential tests

* fix UI and add migration

* fixes

* add logic on book event

* restore comment

* remove dev debug box

* extract min reschedule notice to util

* one more replace

* add to disable reschedule component

* tidy up state

* restore lock

* restore file

* fix zod utils

* respond to cubic feedback

* fix type error

* unit tests

* add zod util

* build tests with nul minReshceuldeNotice

* fix stuff
2025-12-12 10:53:01 -03:00

16 lines
545 B
TypeScript

export function isWithinMinimumRescheduleNotice(
bookingStartTime: Date | null,
minimumRescheduleNotice: number | null
): boolean {
if (!minimumRescheduleNotice || minimumRescheduleNotice <= 0 || !bookingStartTime) {
return false;
}
const now = new Date();
const bookingStart = new Date(bookingStartTime);
const timeUntilBooking = bookingStart.getTime() - now.getTime();
const minimumRescheduleNoticeMs = minimumRescheduleNotice * 60 * 1000;
return timeUntilBooking > 0 && timeUntilBooking < minimumRescheduleNoticeMs;
}