Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/features/bookings/Booker/utils/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { shallow } from "zustand/shallow";
import { useEffect, useRef } from "react";

import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
import { useSchedule } from "@calcom/features/schedules/lib/use-schedule/useSchedule";
Expand Down Expand Up @@ -93,6 +94,10 @@ export const useScheduleForEvent = ({
columnViewExtraDays: { current: number };
};
}) => {
const event = useEvent();
const useBookerTimezone = event.data?.useBookerTimezone;
const hasRestrictionSchedule = !!event.data?.restrictionScheduleId;

const { timezone } = useBookerTime();
const [usernameFromStore, eventSlugFromStore, monthFromStore, durationFromStore] = useBookerStoreContext(
(state) => [state.username, state.eventSlug, state.month, state.selectedDuration],
Expand All @@ -119,6 +124,20 @@ export const useScheduleForEvent = ({
bookerLayout,
});

const prevTimezoneRef = useRef<string | null>(null);

const invalidateSchedule = schedule.invalidate;

useEffect(() => {
const hasTimezoneChanged = prevTimezoneRef.current !== null && timezone !== prevTimezoneRef.current;

if (useBookerTimezone && hasRestrictionSchedule && timezone && hasTimezoneChanged) {
invalidateSchedule();
}

prevTimezoneRef.current = timezone;
}, [timezone, useBookerTimezone, hasRestrictionSchedule, invalidateSchedule]);

return {
data: schedule?.data,
isPending: schedule?.isPending,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export const useApiV2AvailableSlots = ({
rest.skipContactOwner,
rest.teamMemberEmail,
rest.embedConnectVersion ?? false,
rest.timeZone,
rest.duration,
rest.rescheduleUid,
rest.orgSlug,
rest.email,
rest._isDryRun,
],
queryFn: () => {
return axios
Expand Down
Loading