Set buffer time before/after event type (#2015)

* before and after buffer added to handleAvailableSlots function

* --WIP

* added migration

* pull buffer data from DB

* cleanup

* added buffer input in form

* removed unused functions in controller field

* improved the buffer time check

* fixed default value and added preceding event afterbuffer consideration

* fixed e2e test issue

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Syed Ali Shahbazandkodiakhq[bot] authored and GitHub committed 2022-03-04 10:19:03 +00:00
1 parent b77923fc65
commit eeb0cd7e4d
10 files changed
+164 -2

No files matched your search

+35 -1
View File
@@ -30,10 +30,21 @@ type UseSlotsProps = {
date: Dayjs;
users: { username: string | null }[];
schedulingType: SchedulingType | null;
beforeBufferTime?: number;
afterBufferTime?: number;
};
export const useSlots = (props: UseSlotsProps) => {
const { slotInterval, eventLength, minimumBookingNotice = 0, date, users, eventTypeId } = props;
const {
slotInterval,
eventLength,
minimumBookingNotice = 0,
beforeBufferTime = 0,
afterBufferTime = 0,
date,
users,
eventTypeId,
} = props;
const [slots, setSlots] = useState<Slot[]>([]);
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<Error | null>(null);
@@ -124,6 +135,29 @@ export const useSlots = (props: UseSlotsProps) => {
// Check if startTime is between slot
else if (startTime.isBetween(times[i], times[i].add(eventLength, "minutes"))) {
times.splice(i, 1);
}
// Check if time is between afterBufferTime and beforeBufferTime
else if (
times[i].isBetween(
startTime.subtract(beforeBufferTime, "minutes"),
endTime.add(afterBufferTime, "minutes")
)
) {
times.splice(i, 1);
}
// considering preceding event's after buffer time
else if (
i > 0 &&
times[i - 1]
.add(eventLength + afterBufferTime, "minutes")
.isBetween(
startTime.subtract(beforeBufferTime, "minutes"),
endTime.add(afterBufferTime, "minutes"),
null,
"[)"
)
) {
times.splice(i, 1);
} else {
return true;
}
+2
View File
@@ -14,6 +14,8 @@ export type AdvancedOptions = {
requiresConfirmation?: boolean;
disableGuests?: boolean;
minimumBookingNotice?: number;
beforeBufferTime?: number;
afterBufferTime?: number;
slotInterval?: number | null;
price?: number;
currency?: string;