Implements slot logic with the DatePicker, more tests for slots

This commit is contained in:
Alex van Andel
2021-06-30 01:35:08 +00:00
parent 0da99f0d07
commit e78a34e2ce
6 changed files with 177 additions and 134 deletions
+8 -2
View File
@@ -4,10 +4,16 @@ import timezone from "dayjs/plugin/timezone";
dayjs.extend(utc);
dayjs.extend(timezone);
type WorkingHour = {
days: number[];
startTime: number;
endTime: number;
};
type GetSlots = {
inviteeDate: Dayjs;
frequency: number;
workingHours: [];
workingHours: WorkingHour[];
minimumBookingNotice?: number;
organizerTimeZone: string;
};
@@ -110,7 +116,7 @@ const getSlots = ({
organizerTimeZone,
}: GetSlots): Dayjs[] => {
const startTime = dayjs.utc().isSame(dayjs(inviteeDate), "day")
? inviteeDate.hour() * 60 + inviteeDate.minute() + minimumBookingNotice
? inviteeDate.hour() * 60 + inviteeDate.minute() + (minimumBookingNotice || 0)
: 0;
const inviteeBounds = inviteeBoundary(startTime, inviteeDate.utcOffset(), frequency);