Pass event duration to schedule api call (#9484)

This commit is contained in:
Jeroen Reumkens 2023-06-13 12:14:45 +02:00 committed by GitHub
parent 3ec9eb377d
commit 0e76a19c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -37,8 +37,8 @@ export const useEvent = () => {
export const useScheduleForEvent = ({ prefetchNextMonth }: { prefetchNextMonth?: boolean } = {}) => {
const { timezone } = useTimePreferences();
const event = useEvent();
const [username, eventSlug, month] = useBookerStore(
(state) => [state.username, state.eventSlug, state.month],
const [username, eventSlug, month, duration] = useBookerStore(
(state) => [state.username, state.eventSlug, state.month, state.selectedDuration],
shallow
);
@ -49,5 +49,6 @@ export const useScheduleForEvent = ({ prefetchNextMonth }: { prefetchNextMonth?:
month,
timezone,
prefetchNextMonth,
duration,
});
};

View File

@ -8,6 +8,7 @@ type UseScheduleWithCacheArgs = {
month?: string | null;
timezone?: string | null;
prefetchNextMonth?: boolean;
duration?: number | null;
};
export const useSchedule = ({
@ -17,6 +18,7 @@ export const useSchedule = ({
eventSlug,
eventId,
prefetchNextMonth,
duration,
}: UseScheduleWithCacheArgs) => {
const monthDayjs = month ? dayjs(month) : dayjs();
const nextMonthDayjs = monthDayjs.add(1, "month");
@ -35,6 +37,7 @@ export const useSchedule = ({
endTime: (prefetchNextMonth ? nextMonthDayjs : monthDayjs).endOf("month").toISOString(),
timeZone: timezone!,
eventTypeId: eventId!,
duration: duration ? `${duration}` : undefined,
},
{
refetchOnWindowFocus: false,