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

@@ -7,9 +7,10 @@ import {
useBookerStoreContext,
useInitializeBookerStoreContext,
} from "@calcom/features/bookings/Booker/BookerStoreProvider";
import { useBookerLayout } from "@calcom/features/bookings/Booker/hooks/useBookerLayout";
import { useBookingForm } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
import { useLocalSet } from "@calcom/features/bookings/Booker/hooks/useLocalSet";
import { useBookerLayout } from "@calcom/features/bookings/Booker/components/hooks/useBookerLayout";
import { useBookingForm } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm";
import { useLocalSet } from "@calcom/features/bookings/Booker/components/hooks/useLocalSet";
import { useStableTimezone } from "@calcom/features/bookings/Booker/hooks/useStableTimezone";
import { useInitializeBookerStore } from "@calcom/features/bookings/Booker/store";
import { useTimePreferences } from "@calcom/features/bookings/lib";
import type { ConnectedDestinationCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
@@ -243,7 +244,13 @@ const BookerPlatformWrapperComponent = (
return restFormValues;
}, [restFormValues]);
const { timezone } = useTimePreferences();
const { timezone: rawTimezone } = useTimePreferences();
const timezone = useStableTimezone(
rawTimezone,
event?.data?.restrictionScheduleId != null
? { id: event.data.restrictionScheduleId, useBookerTimezone: event.data.useBookerTimezone }
: undefined
);
const [calculatedStartTime, calculatedEndTime] = useTimesForSchedule({
month,
@@ -315,7 +322,7 @@ const BookerPlatformWrapperComponent = (
}
}, [schedule.data, schedule.isPending, schedule.error, onTimeslotsLoaded]);
const bookerForm = useBookingForm({
const bookerForm= useBookingForm({
event: event?.data,
sessionEmail:
session?.data?.email && clientId
@@ -9,6 +9,7 @@ import { Header } from "@calcom/features/bookings/components/Header";
import { BookerSection } from "@calcom/features/bookings/components/Section";
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/hooks/useAvailableTimeSlots";
import { useBookerLayout } from "@calcom/features/bookings/Booker/hooks/useBookerLayout";
import { useStableTimezone } from "@calcom/features/bookings/Booker/hooks/useStableTimezone";
import { useTimePreferences } from "@calcom/features/bookings/lib";
import { LargeCalendar } from "./components/LargeCalendar";
import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents";
@@ -68,7 +69,13 @@ export const EventTypeCalendarViewComponent = (
bookerLayout,
});
const { timezone } = useTimePreferences();
const { timezone: rawTimezone } = useTimePreferences();
const timezone = useStableTimezone(
rawTimezone,
event?.data?.restrictionScheduleId != null
? { id: event.data.restrictionScheduleId, useBookerTimezone: event.data.useBookerTimezone }
: undefined
);
const isDynamic = useMemo(() => {
return getUsernameList(username ?? "").length > 1;
}, [username]);
@@ -112,7 +119,7 @@ export const EventTypeCalendarViewComponent = (
const selectedEventDuration = useBookerStoreContext((state) => state.selectedDuration);
const eventDuration = selectedEventDuration || event?.data?.length || 30;
const availableTimeSlots = useAvailableTimeSlots({ schedule: schedule.data, eventDuration });
const availableTimeSlots= useAvailableTimeSlots({ schedule: schedule.data, eventDuration });
return (
<AtomsWrapper>