feat: Ability to set a locked timezone for event type#22531
feat: Ability to set a locked timezone for event type#22531anikdhabal merged 27 commits intocalcom:mainfrom
Conversation
…into lockedTimezone
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a new optional string property, 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@anikdhabal is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
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: |
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. |
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
packages/lib/server/repository/eventType.ts (1)
783-801: IncludelockedTimeZoneinfindForSlotsto 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"forlockedTimeZonemay not be appropriate for users in other regions. Consider usingnullas the default or making it configurable based on user/organization settings.packages/prisma/selects/event-types.ts (1)
81-136: Consider addinglockedTimeZonetoavailiblityPageEventTypeSelectfor consistency.The
availiblityPageEventTypeSelectis missing thelockedTimeZonefield 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 chainingThe 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 optimizationThe 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
📒 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 goodAdding 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
lockedTimeZonefield 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
lockedTimeZonecolumn 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
lockedTimeZonefield 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 neededThe
PublicEventtype coming from the TRPC router defineslockedTimeZone: string(non-optional), so adding it to theBookerEventPick maintains the correct required status. No type consistency issues remain; approving as is.packages/lib/server/eventTypeSelect.ts (1)
29-32:lockedTimeZonecorrectly added to the shared select object.Nice catch—extending
eventTypeSelectkeeps 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.
lockedTimeZoneis forwarded to the page props, yetgetEventTypesPublic()must also expose this column; otherwise the value will always beundefinedserver-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 trackslockedTimeZone.Looks solid. Make sure the backend DTO (
EventTypeUpdateInput) already acceptslockedTimeZone; 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
lockedTimeZonefield is correctly added to the Prisma select object and logically positioned next to the relatedlockTimeZoneToggleOnBookingPagefield.packages/prisma/selects/event-types.ts (1)
15-15: LGTM! Consistent additions to select objects.The
lockedTimeZonefield is correctly added to bothbaseEventTypeSelectandbookEventTypeSelectobjects.Also applies to: 35-35
packages/prisma/zod-utils.ts (1)
663-663: LGTM! Correctly added to managed properties.The
lockedTimeZonefield is appropriately added to theallManagedEventTypePropsobject, 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 lockedTimeZoneThe test file has been properly updated to include the new
lockedTimeZoneproperty 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 correctlyThe event prop type has been properly extended to include the
lockedTimeZoneproperty, maintaining consistency with the broader changes across the codebase.
228-228: LGTM: Timezone selection logic correctly implementedThe 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 addedThe TimezoneSelect component import has been properly added to support the new timezone selection UI.
1006-1007: LGTM: Conditional styling for visual continuityThe conditional styling correctly removes bottom rounding when the toggle is active, providing seamless visual connection between the toggle and the nested timezone selector.
|
@anikdhabal can we add some test here? |
E2E results are ready! |
What does this PR do?
fixes CAL-5180