Skip to content

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

Merged
volnei merged 48 commits intomainfrom
fix/slots-refresh-on-timezone-change
Feb 17, 2026
Merged

fix: refresh slots on timezone change for booker timezone restrictions#27491
volnei merged 48 commits intomainfrom
fix/slots-refresh-on-timezone-change

Conversation

@alishaz-polymath
Copy link
Copy Markdown
Member

@alishaz-polymath alishaz-polymath commented Feb 2, 2026

What does this PR do?

Fixes timezone-based slot refresh behavior when event types have restriction schedules that use the booker's timezone. When a user changes their timezone in the booking widget, the available slots now correctly refresh to reflect the new timezone constraints.

Continues work from #26026

Changes

  1. useStableTimezone shared hook (packages/features/bookings/Booker/hooks/useStableTimezone.ts):

    • Encapsulates the timezone-pinning logic: when an event has a restriction schedule with useBookerTimezone: false, the timezone is pinned to the initial value (preventing unnecessary refetches). Otherwise, it follows the booker's current timezone.
    • Used in all three call sites: useScheduleForEvent, BookerPlatformWrapper, and EventTypeCalendarViewComponent.
    • 8 unit tests covering all branches.
  2. Type fixes:

    • Added useBookerTimezone and restrictionScheduleId to BookerEvent Pick list (picked directly from PublicEvent)
    • Explicitly included these fields in getPublicEvent return value (both for regular and dynamic event types)
    • Added explicit Promise<PublicEventType> return type to event.handler.ts to ensure tRPC properly propagates the type chain
    • Expanded BookerEventProfile to include brandColor, darkBrandColor, theme, weekStart, username
  3. Stable timezone in schedule hooks:

    • useScheduleForEvent accepts a restrictionSchedule: { id, useBookerTimezone } prop and delegates to useStableTimezone.
    • BookerPlatformWrapper and EventTypeCalendarViewComponent construct the restrictionSchedule object from event.data and call useStableTimezone directly.
  4. Dead code removal:

    • Removed useTimezoneBasedSlotRefresh.ts, useTimezoneBasedSlotRefresh.test.ts, useTimezoneChangeDetection.ts, useTimezoneChangeDetection.test.ts — these were leftovers from the earlier callback-based approach, no longer imported by any component.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - no docs changes needed.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Create an event type with a restriction schedule that has useBookerTimezone enabled
  2. Open the booking page
  3. Change the timezone in the booker widget
  4. Verify that the available slots refresh to reflect the new timezone

Expected behavior: Slots should refresh when timezone changes and the event has a restriction schedule using booker timezone. When useBookerTimezone is false, changing timezone should not trigger a refetch (timezone is pinned to the initial value).

Human Review Checklist

  • Verify useStableTimezone correctly captures the initial timezone on mount (uses useRef) — if the component remounts, the ref resets. Confirm this is acceptable for the booker flow.
  • Verify the restrictionSchedule prop construction at each of the three call sites correctly maps event.data.restrictionScheduleId and event.data.useBookerTimezone.
  • Minor: There are formatting issues with missing spaces before = in bookerForm= and availableTimeSlots= — these should be auto-fixed by linter but weren't flagged as errors.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my changes generate no new warnings

Link to Devin run: https://app.devin.ai/sessions/d9b2bc5dbc7a482ab580d5bc843576ce
Requested by: @alishaz-polymath

hackice20 and others added 30 commits December 18, 2025 18:41
Add timezone change detection and slot refresh to BookerPlatformWrapper
and EventTypeCalendarViewComponent to handle restriction schedules with
useBookerTimezone enabled.
…ponent.tsx

Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
…ponent.tsx

Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
@Udit-takkar Udit-takkar marked this pull request as draft February 6, 2026 12:28
devin-ai-integration bot and others added 2 commits February 13, 2026 12:27
Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
@alishaz-polymath alishaz-polymath marked this pull request as ready for review February 13, 2026 12:33
@devin-ai-integration devin-ai-integration bot changed the title fix: correct import paths and type exports for timezone slot refresh fix: refresh slots on timezone change for booker timezone restrictions Feb 13, 2026
@alishaz-polymath alishaz-polymath added run-ci Approve CI to run for external contributors and removed run-ci Approve CI to run for external contributors labels Feb 13, 2026
…opagation

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code: useTimezoneBasedSlotRefresh and useTimezoneChangeDetection are not imported by any component — they're only referenced by each other and their own test files. These are leftovers from the earlier callback-based approach that was replaced by the inline useRef timezone-pinning pattern. These four files should be removed:

  • useTimezoneBasedSlotRefresh.ts
  • useTimezoneBasedSlotRefresh.test.ts
  • useTimezoneChangeDetection.ts
  • useTimezoneChangeDetection.test.ts

Duplicated logic — extract a shared hook. The same timezone-pinning pattern is copy-pasted in three places:

  • useEvent.ts:105-111
  • BookerPlatformWrapper.tsx:247-251
  • EventTypeCalendarViewComponent.tsx:72-76

Consider extracting a small shared hook, e.g.:

export function useStableTimezone(  timezone: string,  restrictionSchedule?: { id: number | null; useBookerTimezone: boolean }): string {  const initialRef = useRef(timezone);  const shouldPin =    restrictionSchedule?.id != null &&    restrictionSchedule.id > 0 &&    restrictionSchedule.useBookerTimezone === false;  return shouldPin ? initialRef.current : timezone;}

Each call site then becomes a one-liner. This also gives a single place to add tests (which could replace the now-dead useTimezoneChangeDetection tests).

@github-actions github-actions bot marked this pull request as draft February 16, 2026 09:09
…ection code

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

Addressed both items from the latest review:

  1. Removed dead code — deleted all 4 files (useTimezoneBasedSlotRefresh.ts, useTimezoneBasedSlotRefresh.test.ts, useTimezoneChangeDetection.ts, useTimezoneChangeDetection.test.ts). Confirmed no other references exist in the codebase.

  2. Extracted useStableTimezone hook — the duplicated timezone-pinning pattern from useScheduleForEvent, BookerPlatformWrapper, and EventTypeCalendarViewComponent is now a single shared hook in packages/features/bookings/Booker/hooks/useStableTimezone.ts. Each call site is now a one-liner. Added 8 tests covering all branches.

@alishaz-polymath alishaz-polymath marked this pull request as ready for review February 16, 2026 09:50
@alishaz-polymath alishaz-polymath added run-ci Approve CI to run for external contributors and removed run-ci Approve CI to run for external contributors labels Feb 16, 2026
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !!

Copy link
Copy Markdown
Contributor

@volnei volnei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@volnei volnei merged commit 4c73695 into main Feb 17, 2026
84 of 87 checks passed
@volnei volnei deleted the fix/slots-refresh-on-timezone-change branch February 17, 2026 10:46
285729101 pushed a commit to 285729101/cal.com that referenced this pull request Feb 17, 2026
calcom#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 <52925846+alishaz-polymath@users.noreply.github.com>

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

Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>

* 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: ali@cal.com <alishahbaz7@gmail.com>

* fix: explicitly include restrictionScheduleId and useBookerTimezone in getPublicEvent return

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

* chore: trigger fresh CI build

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

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

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

* refactor: address review feedback for timezone slot refresh

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

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

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

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

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

---------

Co-authored-by: hackice20 <yashkam431@gmail.com>
Co-authored-by: Yash <116657771+hackice20@users.noreply.github.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
285729101 pushed a commit to 285729101/cal.com that referenced this pull request Feb 17, 2026
calcom#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 <52925846+alishaz-polymath@users.noreply.github.com>

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

Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>

* 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


* fix: explicitly include restrictionScheduleId and useBookerTimezone in getPublicEvent return


* chore: trigger fresh CI build


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


* refactor: address review feedback for timezone slot refresh


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


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


---------

Co-authored-by: hackice20 <yashkam431@gmail.com>
Co-authored-by: Yash <116657771+hackice20@users.noreply.github.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
emrysal pushed a commit that referenced this pull request Feb 18, 2026
#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 <52925846+alishaz-polymath@users.noreply.github.com>

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

Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>

* 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: ali@cal.com <alishahbaz7@gmail.com>

* fix: explicitly include restrictionScheduleId and useBookerTimezone in getPublicEvent return

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

* chore: trigger fresh CI build

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

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

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

* refactor: address review feedback for timezone slot refresh

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

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

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

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

Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>

---------

Co-authored-by: hackice20 <yashkam431@gmail.com>
Co-authored-by: Yash <116657771+hackice20@users.noreply.github.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ✅ good first issue Good for newcomers High priority Created by Linear-GitHub Sync ⚡ Quick Wins A collection of quick wins/quick fixes that are less than 30 minutes of work ready-for-e2e run-ci Approve CI to run for external contributors size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upon changing timezone, we need to update slots when restrictionSchedule is being used with useBookerTimezone enabled

6 participants