@@ -12,6 +12,7 @@ import {
1212} from "@calcom/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper" ;
1313import getLocationsOptionsForSelect from "@calcom/features/bookings/lib/getLocationOptionsForSelect" ;
1414import DestinationCalendarSelector from "@calcom/features/calendars/DestinationCalendarSelector" ;
15+ import { TimezoneSelect } from "@calcom/features/components/timezone-select" ;
1516import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager" ;
1617import {
1718 allowDisablingAttendeeConfirmationEmails ,
@@ -1033,23 +1034,63 @@ export const EventAdvancedTab = ({
10331034 />
10341035 < Controller
10351036 name = "lockTimeZoneToggleOnBookingPage"
1036- render = { ( { field : { value, onChange } } ) => (
1037- < SettingsToggle
1038- labelClassName = { classNames ( "text-sm" , customClassNames ?. timezoneLock ?. label ) }
1039- descriptionClassName = { customClassNames ?. timezoneLock ?. description }
1040- toggleSwitchAtTheEnd = { true }
1041- switchContainerClassName = { classNames (
1042- "border-subtle rounded-lg border py-6 px-4 sm:px-6" ,
1043- customClassNames ?. timezoneLock ?. container
1044- ) }
1045- title = { t ( "lock_timezone_toggle_on_booking_page" ) }
1046- { ...lockTimeZoneToggleOnBookingPageLocked }
1047- description = { t ( "description_lock_timezone_toggle_on_booking_page" ) }
1048- checked = { value }
1049- onCheckedChange = { ( e ) => onChange ( e ) }
1050- data-testid = "lock-timezone-toggle"
1051- />
1052- ) }
1037+ render = { ( { field : { value, onChange } } ) => {
1038+ // Calculate if we should show the selector based on current form state & handle backward compatibility
1039+ const currentLockedTimeZone = formMethods . getValues ( "lockedTimeZone" ) ;
1040+ const showSelector =
1041+ value &&
1042+ ( ! ( eventType . lockTimeZoneToggleOnBookingPage && ! eventType . lockedTimeZone ) ||
1043+ ! ! currentLockedTimeZone ) ;
1044+
1045+ return (
1046+ < SettingsToggle
1047+ labelClassName = { classNames ( "text-sm" , customClassNames ?. timezoneLock ?. label ) }
1048+ descriptionClassName = { customClassNames ?. timezoneLock ?. description }
1049+ toggleSwitchAtTheEnd = { true }
1050+ switchContainerClassName = { classNames (
1051+ "border-subtle rounded-lg border py-6 px-4 sm:px-6" ,
1052+ customClassNames ?. timezoneLock ?. container ,
1053+ showSelector && "rounded-b-none"
1054+ ) }
1055+ title = { t ( "lock_timezone_toggle_on_booking_page" ) }
1056+ { ...lockTimeZoneToggleOnBookingPageLocked }
1057+ description = { t ( "description_lock_timezone_toggle_on_booking_page" ) }
1058+ checked = { value }
1059+ onCheckedChange = { ( e ) => {
1060+ onChange ( e ) ;
1061+ const lockedTimeZone = e ? eventType . lockedTimeZone ?? "Europe/London" : null ;
1062+ formMethods . setValue ( "lockedTimeZone" , lockedTimeZone , { shouldDirty : true } ) ;
1063+ } }
1064+ data-testid = "lock-timezone-toggle"
1065+ childrenClassName = "lg:ml-0" >
1066+ { showSelector && (
1067+ < div className = "border-subtle flex flex-col gap-6 rounded-b-lg border border-t-0 p-6" >
1068+ < div >
1069+ < Controller
1070+ name = "lockedTimeZone"
1071+ control = { formMethods . control }
1072+ render = { ( { field : { value } } ) => (
1073+ < >
1074+ < Label className = "text-default mb-2 block text-sm font-medium" >
1075+ < > { t ( "timezone" ) } </ >
1076+ </ Label >
1077+ < TimezoneSelect
1078+ id = "lockedTimeZone"
1079+ value = { value ?? "Europe/London" }
1080+ onChange = { ( event ) => {
1081+ if ( event )
1082+ formMethods . setValue ( "lockedTimeZone" , event . value , { shouldDirty : true } ) ;
1083+ } }
1084+ />
1085+ </ >
1086+ ) }
1087+ />
1088+ </ div >
1089+ </ div >
1090+ ) }
1091+ </ SettingsToggle >
1092+ ) ;
1093+ } }
10531094 />
10541095 < Controller
10551096 name = "allowReschedulingPastBookings"
0 commit comments