Skip to content

Commit 293dd1a

Browse files
authored
Fix: lock timezone on booking page breaks atoms (#23060)
* fix: eventTypeSettings atom crashed on enabling `Lock timezone on booking page` * add changelog
1 parent b7fda31 commit 293dd1a

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

.changeset/deep-owls-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@calcom/atoms": minor
3+
---
4+
5+
fix: EventTypeSettings Atom crashes on enabling `Lock timezone on booking` in advanced tab

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, Suspense } from "react";
1+
import { useState, Suspense, useMemo } from "react";
22
import type { Dispatch, SetStateAction } from "react";
33
import { Controller, useFormContext } from "react-hook-form";
44
import type { z } from "zod";
@@ -10,9 +10,10 @@ import {
1010
SelectedCalendarSettingsScope,
1111
SelectedCalendarsSettingsWebWrapperSkeleton,
1212
} from "@calcom/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper";
13+
import { Timezone as PlatformTimzoneSelect } from "@calcom/atoms/timezone";
1314
import getLocationsOptionsForSelect from "@calcom/features/bookings/lib/getLocationOptionsForSelect";
1415
import DestinationCalendarSelector from "@calcom/features/calendars/DestinationCalendarSelector";
15-
import { TimezoneSelect } from "@calcom/features/components/timezone-select";
16+
import { TimezoneSelect as WebTimezoneSelect } from "@calcom/features/components/timezone-select";
1617
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
1718
import {
1819
allowDisablingAttendeeConfirmationEmails,
@@ -565,6 +566,10 @@ export const EventAdvancedTab = ({
565566
userEmail = removePlatformClientIdFromEmail(userEmail, platformContext.clientId);
566567
}
567568

569+
const TimezoneSelect = useMemo(() => {
570+
return isPlatform ? PlatformTimzoneSelect : WebTimezoneSelect;
571+
}, [isPlatform]);
572+
568573
return (
569574
<div className="flex flex-col space-y-4">
570575
<calendarComponents.CalendarSettings

packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const EventType = forwardRef<
150150
const description = message ? t(message) : t(err.message);
151151
toast({ description });
152152
onError?.(currentValues, err);
153-
153+
154154
const errorObj = new Error(description);
155155
callbacksRef.current?.onError?.(errorObj);
156156
},
@@ -175,24 +175,27 @@ const EventType = forwardRef<
175175

176176
const callbacksRef = useRef<{ onSuccess?: () => void; onError?: (error: Error) => void }>({});
177177

178-
const handleFormSubmit = useCallback((customCallbacks?: { onSuccess?: () => void; onError?: (error: Error) => void }) => {
179-
if (customCallbacks) {
180-
callbacksRef.current = customCallbacks;
181-
}
178+
const handleFormSubmit = useCallback(
179+
(customCallbacks?: { onSuccess?: () => void; onError?: (error: Error) => void }) => {
180+
if (customCallbacks) {
181+
callbacksRef.current = customCallbacks;
182+
}
182183

183-
if (saveButtonRef.current) {
184-
saveButtonRef.current.click();
185-
} else {
186-
form.handleSubmit((data) => {
187-
try {
188-
handleSubmit(data);
189-
customCallbacks?.onSuccess?.();
190-
} catch (error) {
191-
customCallbacks?.onError?.(error as Error);
192-
}
193-
})();
194-
}
195-
}, [handleSubmit, form]);
184+
if (saveButtonRef.current) {
185+
saveButtonRef.current.click();
186+
} else {
187+
form.handleSubmit((data) => {
188+
try {
189+
handleSubmit(data);
190+
customCallbacks?.onSuccess?.();
191+
} catch (error) {
192+
customCallbacks?.onError?.(error as Error);
193+
}
194+
})();
195+
}
196+
},
197+
[handleSubmit, form]
198+
);
196199

197200
const validateForm = useCallback(async () => {
198201
const isValid = await form.trigger();

0 commit comments

Comments
 (0)