fix: refresh slots on timezone change for booker timezone restrictions (#27491)

* fix: refresh slots on timezone change for booker timezone restrictions

* refactor: use useMemo for timezone change detection

* revert: remove unnecessary formatting changes

* feat: add timezone refresh for platform components

Add timezone change detection and slot refresh to BookerPlatformWrapper
and EventTypeCalendarViewComponent to handle restriction schedules with
useBookerTimezone enabled.

* refactor: extract timezone slot refresh logic into reusable hook

* Update packages/platform/atoms/calendar-view/EventTypeCalendarViewComponent.tsx

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* Update packages/platform/atoms/calendar-view/EventTypeCalendarViewComponent.tsx

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* fix

* fix: prevent unnecessary getSchedule calls when useBookerTimezone is disabled

* fix: add timezone fields to BookerEvent type

* fix: add missing properties to BookerEvent and BookerEventProfile types

* trying to fix type errors

* Add restrictionScheduleId and useBookerTimezone fields

* fix: correct import path for useBookerTime hook

Co-Authored-By: [email protected] <[email protected]>

* fix: explicitly include restrictionScheduleId and useBookerTimezone in getPublicEvent return

Co-Authored-By: [email protected] <[email protected]>

* chore: trigger fresh CI build

Co-Authored-By: [email protected] <[email protected]>

* fix: cast event.data to BookerEvent for timezone fields access

Co-Authored-By: [email protected] <[email protected]>

* refactor: address review feedback for timezone slot refresh

Co-Authored-By: [email protected] <[email protected]>

* refactor: add explicit return type to event handler to ensure type propagation

Co-Authored-By: [email protected] <[email protected]>

* refactor: extract useStableTimezone hook and remove dead timezone detection code

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: hackice20 <[email protected]>
Co-authored-by: Yash <[email protected]>
Co-authored-by: Morgan <[email protected]>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-02-17 07:46:40 -03:00
1 parent ab4eff1fe1
commit 4c73695d3a
9 files changed
+140 -22

No files matched your search

@@ -19,7 +19,7 @@ import { useInitializeBookerStore } from "@calcom/features/bookings/Booker/store
import { useEvent, useScheduleForEvent } from "@calcom/web/modules/schedules/hooks/useEvent";
import { useBrandColors } from "@calcom/features/bookings/Booker/utils/use-brand-colors";
import type { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";
import { DEFAULT_DARK_BRAND_COLOR, DEFAULT_LIGHT_BRAND_COLOR, WEBAPP_URL } from "@calcom/lib/constants";
import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR, WEBAPP_URL } from "@calcom/lib/constants";
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
import { localStorage } from "@calcom/lib/webstorage";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
@@ -42,11 +42,11 @@ const BookerWebWrapperComponent = (props: BookerWebWrapperAtomProps): JSX.Elemen
});
const event = props.eventData
? {
data: props.eventData,
isSuccess: true,
isError: false,
isPending: false,
}
data: props.eventData,
isSuccess: true,
isError: false,
isPending: false,
}
: clientFetchedEvent;
const bookerLayout = useBookerLayout(event.data?.profile?.bookerLayouts);
@@ -149,6 +149,9 @@ const BookerWebWrapperComponent = (props: BookerWebWrapperAtomProps): JSX.Elemen
useApiV2: props.useApiV2,
bookerLayout,
...(props.entity.orgSlug ? { orgSlug: props.entity.orgSlug } : {}),
restrictionSchedule: event.data?.restrictionScheduleId
? { id: event.data.restrictionScheduleId, useBookerTimezone: event.data.useBookerTimezone }
: undefined,
});
const bookings = useBookings({
event,
+7 -2
View File
@@ -6,6 +6,7 @@ import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { trpc } from "@calcom/trpc/react";
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
import { useStableTimezone } from "@calcom/features/bookings/Booker/hooks/useStableTimezone";
export type useEventReturnType = ReturnType<typeof useEvent>;
export type useScheduleForEventReturnType = ReturnType<typeof useScheduleForEvent>;
@@ -71,6 +72,7 @@ export const useScheduleForEvent = ({
isTeamEvent,
useApiV2 = true,
bookerLayout,
restrictionSchedule,
}: {
username?: string | null;
eventSlug?: string | null;
@@ -92,13 +94,16 @@ export const useScheduleForEvent = ({
extraDays: number;
columnViewExtraDays: { current: number };
};
restrictionSchedule?: { id: number | null; useBookerTimezone: boolean };
}) => {
const { timezone } = useBookerTime();
const { timezone: rawTimezone } = useBookerTime();
const [usernameFromStore, eventSlugFromStore, monthFromStore, durationFromStore] = useBookerStoreContext(
(state) => [state.username, state.eventSlug, state.month, state.selectedDuration],
shallow
);
const effectiveTimezone = useStableTimezone(rawTimezone, restrictionSchedule);
const searchParams = useCompatSearchParams();
const rescheduleUid = searchParams?.get("rescheduleUid");
@@ -106,7 +111,7 @@ export const useScheduleForEvent = ({
username: usernameFromStore ?? username,
eventSlug: eventSlugFromStore ?? eventSlug,
eventId,
timezone,
timezone: effectiveTimezone,
selectedDate,
dayCount,
rescheduleUid,