Skip to content

feat: Ability to set a locked timezone for event type#22531

Merged
anikdhabal merged 27 commits intocalcom:mainfrom
anikdhabal:locked_timezone
Jul 29, 2025
Merged

feat: Ability to set a locked timezone for event type#22531
anikdhabal merged 27 commits intocalcom:mainfrom
anikdhabal:locked_timezone

Conversation

@anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented Jul 15, 2025

What does this PR do?

fixes CAL-5180

image

@anikdhabal anikdhabal requested review from a team July 15, 2025 15:43
@anikdhabal anikdhabal requested a review from a team as a code owner July 15, 2025 15:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 15, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a new optional string property, lockedTimeZone, to the EventType model and its associated types, forms, UI components, and database queries throughout the codebase. The Prisma schema is updated to include this field, and a migration script modifies the database to allow null values for lockedTimeZone. Selection objects and validators for event types are extended to include this property in all relevant queries and data structures. UI components and forms are updated to support selecting and displaying the locked timezone when the corresponding toggle is enabled. Test data and default event objects are also updated to include the new field. No changes are made to logic or control flow outside of supporting this new property.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel
Copy link

vercel bot commented Jul 15, 2025

@anikdhabal is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Contributor

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Locked timezone". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@graphite-app graphite-app bot requested a review from a team July 15, 2025 15:43
@github-actions github-actions bot added the ❗️ migrations contains migration files label Jul 15, 2025
@keithwillcode keithwillcode added the core area: core, team members only label Jul 15, 2025
@anikdhabal anikdhabal changed the title Locked timezone feat: Ability to set a locked timezone for event type Jul 15, 2025
@graphite-app
Copy link

graphite-app bot commented Jul 15, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (07/15/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (07/29/25)

1 label was added to this PR based on Keith Williams's automation.

@dosubot dosubot bot added the bookings area: bookings, availability, timezones, double booking label Jul 15, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/lib/server/repository/eventType.ts (1)

783-801: Include lockedTimeZone in findForSlots to avoid mismatched data.

findForSlots() powers slot-generation logic. Without the new column, the booking flow cannot honour a locked timezone and may default to the caller’s locale.

@@
         timeZone: true,
+        lockedTimeZone: true,           // <- prevents slot calculation drift
+        lockTimeZoneToggleOnBookingPage: true,
🧹 Nitpick comments (5)
packages/lib/test/builder.ts (1)

112-116: Test builder updated – keep the default in sync with production defaults.

All good. Consider exposing the default value through a constant so the same string isn’t repeated across code and tests.

packages/lib/defaultEvents.ts (1)

103-103: Consider using a more neutral default timezone or making it configurable.

The hardcoded default value "Europe/London" for lockedTimeZone may not be appropriate for users in other regions. Consider using null as the default or making it configurable based on user/organization settings.

packages/prisma/selects/event-types.ts (1)

81-136: Consider adding lockedTimeZone to availiblityPageEventTypeSelect for consistency.

The availiblityPageEventTypeSelect is missing the lockedTimeZone field while other select objects include it. This could cause issues if timezone locking information is needed in availability contexts.

export const availiblityPageEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
  id: true,
  title: true,
  availability: true,
  description: true,
  length: true,
  offsetStart: true,
  price: true,
  currency: true,
  periodType: true,
  periodStartDate: true,
  periodEndDate: true,
  periodDays: true,
  periodCountCalendarDays: true,
  locations: true,
  schedulingType: true,
  recurringEvent: true,
  requiresConfirmation: true,
  schedule: {
    select: {
      availability: true,
      timeZone: true,
    },
  },
  hidden: true,
  userId: true,
  slug: true,
  minimumBookingNotice: true,
  beforeEventBuffer: true,
  afterEventBuffer: true,
  timeZone: true,
  metadata: true,
  slotInterval: true,
  seatsPerTimeSlot: true,
+  lockedTimeZone: true,
  users: {
    select: {
      id: true,
      avatarUrl: true,
      name: true,
      username: true,
      hideBranding: true,
      timeZone: true,
    },
  },
  team: {
    select: {
      logoUrl: true,
      parent: {
        select: {
          logoUrl: true,
          name: true,
        },
      },
    },
  },
});
packages/features/bookings/Booker/components/EventMeta.tsx (1)

112-115: Simplify the condition using optional chaining

The condition can be simplified using optional chaining as suggested by the static analysis tool.

-  //In case the event has lockTimeZone enabled ,set the timezone to event's locked timezone
-  if (event && event?.lockTimeZoneToggleOnBookingPage && event?.lockedTimeZone) {
-    setTimezone(event?.lockedTimeZone);
+  //In case the event has lockTimeZone enabled, set the timezone to event's locked timezone
+  if (event?.lockTimeZoneToggleOnBookingPage && event?.lockedTimeZone) {
+    setTimezone(event.lockedTimeZone);
   }
packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx (1)

1015-1039: Well-implemented timezone selector UI with minor fragment optimization

The timezone selector UI is properly implemented with Controller binding and form state management. The conditional rendering ensures the selector only appears when the toggle is enabled.

Address the static analysis hint by removing the unnecessary Fragment:

-                      <Label className="text-default mb-2 block text-sm font-medium">
-                        <>{t("timezone")}</>
-                      </Label>
+                      <Label className="text-default mb-2 block text-sm font-medium">
+                        {t("timezone")}
+                      </Label>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee7b12 and cb4e52e.

📒 Files selected for processing (19)
  • apps/web/server/lib/[user]/getServerSideProps.ts (1 hunks)
  • apps/web/test/lib/handleChildrenEventTypes.test.ts (12 hunks)
  • docs/platform/guides/teams-setup.mdx (1 hunks)
  • packages/features/bookings/Booker/components/EventMeta.tsx (3 hunks)
  • packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts (1 hunks)
  • packages/features/bookings/types.ts (1 hunks)
  • packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx (2 hunks)
  • packages/features/eventtypes/lib/getPublicEvent.ts (1 hunks)
  • packages/features/eventtypes/lib/types.ts (1 hunks)
  • packages/lib/defaultEvents.ts (1 hunks)
  • packages/lib/event-types/getEventTypesPublic.ts (2 hunks)
  • packages/lib/server/eventTypeSelect.ts (1 hunks)
  • packages/lib/server/repository/eventType.ts (1 hunks)
  • packages/lib/test/builder.ts (1 hunks)
  • packages/platform/atoms/event-types/hooks/useEventTypeForm.ts (1 hunks)
  • packages/prisma/migrations/20250715154135_locked_timezone/migration.sql (1 hunks)
  • packages/prisma/schema.prisma (1 hunks)
  • packages/prisma/selects/event-types.ts (2 hunks)
  • packages/prisma/zod-utils.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/web/test/lib/handleChildrenEventTypes.test.ts (1)
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
🪛 Biome (1.9.4)
packages/features/bookings/Booker/components/EventMeta.tsx

[error] 113-113: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx

[error] 1024-1024: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Security Check
🔇 Additional comments (18)
docs/platform/guides/teams-setup.mdx (1)

248-248: EOF newline addition looks good

Adding a trailing newline is a harmless tweak that aligns with POSIX tooling expectations. No further action needed.

packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts (1)

61-61: LGTM! Field addition is correct.

The lockedTimeZone field is properly added to the Prisma select query, following the established pattern of other fields in the select object.

packages/prisma/migrations/20250715154135_locked_timezone/migration.sql (1)

1-3: LGTM! Migration correctly makes the field optional.

The migration properly converts the lockedTimeZone column from NOT NULL to nullable by dropping both the NOT NULL constraint and the default value, allowing the field to accept null values.

packages/prisma/schema.prisma (1)

111-111: LGTM! Schema field addition is correct.

The lockedTimeZone field is properly added as an optional string (String?) to the EventType model, which correctly aligns with the migration that makes the database column nullable.

packages/features/bookings/types.ts (1)

49-49: lockedTimeZone optionality is correct – no further action needed

The PublicEvent type coming from the TRPC router defines lockedTimeZone: string (non-optional), so adding it to the BookerEvent Pick maintains the correct required status. No type consistency issues remain; approving as is.

packages/lib/server/eventTypeSelect.ts (1)

29-32: lockedTimeZone correctly added to the shared select object.

Nice catch—extending eventTypeSelect keeps downstream queries in sync with the new column.

apps/web/server/lib/[user]/getServerSideProps.ts (1)

60-64: Prop list updated, but double-check upstream query includes the field.

lockedTimeZone is forwarded to the page props, yet getEventTypesPublic() must also expose this column; otherwise the value will always be undefined server-side. Verify that file already selects the field (the AI summary says it does, but worth compiling to be sure).

packages/platform/atoms/event-types/hooks/useEventTypeForm.ts (1)

54-58: Default form state now tracks lockedTimeZone.

Looks solid. Make sure the backend DTO (EventTypeUpdateInput) already accepts lockedTimeZone; otherwise a silent drop may occur when the form is submitted.

packages/lib/server/repository/eventType.ts (1)

488-492: Field added to the “complete” select – good.

packages/features/eventtypes/lib/getPublicEvent.ts (1)

70-70: LGTM! Well-positioned addition.

The lockedTimeZone field is correctly added to the Prisma select object and logically positioned next to the related lockTimeZoneToggleOnBookingPage field.

packages/prisma/selects/event-types.ts (1)

15-15: LGTM! Consistent additions to select objects.

The lockedTimeZone field is correctly added to both baseEventTypeSelect and bookEventTypeSelect objects.

Also applies to: 35-35

packages/prisma/zod-utils.ts (1)

663-663: LGTM! Correctly added to managed properties.

The lockedTimeZone field is appropriately added to the allManagedEventTypeProps object, marking it as a manageable property for event types.

packages/lib/event-types/getEventTypesPublic.ts (1)

38-38: LGTM! Consistently added across all SELECT statements.

The "lockedTimeZone" column is correctly added to all three SELECT statements in the UNION query, maintaining consistency with the database schema.

Also applies to: 45-45, 55-55

apps/web/test/lib/handleChildrenEventTypes.test.ts (1)

114-114: LGTM: Consistent test data updates for lockedTimeZone

The test file has been properly updated to include the new lockedTimeZone property with consistent test data across all scenarios. The use of "Europe/London" as a test value is appropriate and maintains consistency with the default event type builder mentioned in the summary.

Also applies to: 140-140, 173-173, 204-204, 279-279, 312-312, 339-339, 373-373, 404-404, 430-430, 465-465, 492-492

packages/features/bookings/Booker/components/EventMeta.tsx (2)

59-59: LGTM: Event prop type updated correctly

The event prop type has been properly extended to include the lockedTimeZone property, maintaining consistency with the broader changes across the codebase.


228-228: LGTM: Timezone selection logic correctly implemented

The TimezoneSelect component properly uses the locked timezone when the lock toggle is enabled, providing the expected user experience for the locked timezone feature.

packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx (2)

15-15: LGTM: TimezoneSelect import added

The TimezoneSelect component import has been properly added to support the new timezone selection UI.


1006-1007: LGTM: Conditional styling for visual continuity

The conditional styling correctly removes bottom rounding when the toggle is active, providing seamless visual connection between the toggle and the nested timezone selector.

@anikdhabal anikdhabal marked this pull request as draft July 15, 2025 16:08
@anikdhabal anikdhabal marked this pull request as ready for review July 16, 2025 13:03
@dosubot dosubot bot added event-types area: event types, event-types ✨ feature New feature or request labels Jul 16, 2025
@anikdhabal anikdhabal enabled auto-merge (squash) July 16, 2025 13:21
Udit-takkar
Udit-takkar previously approved these changes Jul 18, 2025
Copy link
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

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

LGTM

@Udit-takkar
Copy link
Contributor

@anikdhabal can we add some test here?

Copy link
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@anikdhabal anikdhabal merged commit a11ea3d into calcom:main Jul 29, 2025
54 of 59 checks passed
@github-actions
Copy link
Contributor

E2E results are ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking core area: core, team members only event-types area: event types, event-types ✨ feature New feature or request ❗️ migrations contains migration files ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants