feat: Ability to set a locked timezone for event type (#22531)
* feat: ability to set locked timezone * update * Update update-event-type.input.ts * Update get-event-type-public.output.ts * Update documentation.json * revert * nit * feat: locked timezone * update * fix * Update handleChildrenEventTypes.test.ts * update * fix test
This commit is contained in:
1 parent
b21400c613
commit
a11ea3dd1e
20 files changed
+119
-26
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
} from "@calcom/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsWebWrapper";
|
||||
import getLocationsOptionsForSelect from "@calcom/features/bookings/lib/getLocationOptionsForSelect";
|
||||
import DestinationCalendarSelector from "@calcom/features/calendars/DestinationCalendarSelector";
|
||||
import { TimezoneSelect } from "@calcom/features/components/timezone-select";
|
||||
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
|
||||
import {
|
||||
allowDisablingAttendeeConfirmationEmails,
|
||||
@@ -1033,23 +1034,63 @@ export const EventAdvancedTab = ({
|
||||
/>
|
||||
<Controller
|
||||
name="lockTimeZoneToggleOnBookingPage"
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<SettingsToggle
|
||||
labelClassName={classNames("text-sm", customClassNames?.timezoneLock?.label)}
|
||||
descriptionClassName={customClassNames?.timezoneLock?.description}
|
||||
toggleSwitchAtTheEnd={true}
|
||||
switchContainerClassName={classNames(
|
||||
"border-subtle rounded-lg border py-6 px-4 sm:px-6",
|
||||
customClassNames?.timezoneLock?.container
|
||||
)}
|
||||
title={t("lock_timezone_toggle_on_booking_page")}
|
||||
{...lockTimeZoneToggleOnBookingPageLocked}
|
||||
description={t("description_lock_timezone_toggle_on_booking_page")}
|
||||
checked={value}
|
||||
onCheckedChange={(e) => onChange(e)}
|
||||
data-testid="lock-timezone-toggle"
|
||||
/>
|
||||
)}
|
||||
render={({ field: { value, onChange } }) => {
|
||||
// Calculate if we should show the selector based on current form state & handle backward compatibility
|
||||
const currentLockedTimeZone = formMethods.getValues("lockedTimeZone");
|
||||
const showSelector =
|
||||
value &&
|
||||
(!(eventType.lockTimeZoneToggleOnBookingPage && !eventType.lockedTimeZone) ||
|
||||
!!currentLockedTimeZone);
|
||||
|
||||
return (
|
||||
<SettingsToggle
|
||||
labelClassName={classNames("text-sm", customClassNames?.timezoneLock?.label)}
|
||||
descriptionClassName={customClassNames?.timezoneLock?.description}
|
||||
toggleSwitchAtTheEnd={true}
|
||||
switchContainerClassName={classNames(
|
||||
"border-subtle rounded-lg border py-6 px-4 sm:px-6",
|
||||
customClassNames?.timezoneLock?.container,
|
||||
showSelector && "rounded-b-none"
|
||||
)}
|
||||
title={t("lock_timezone_toggle_on_booking_page")}
|
||||
{...lockTimeZoneToggleOnBookingPageLocked}
|
||||
description={t("description_lock_timezone_toggle_on_booking_page")}
|
||||
checked={value}
|
||||
onCheckedChange={(e) => {
|
||||
onChange(e);
|
||||
const lockedTimeZone = e ? eventType.lockedTimeZone ?? "Europe/London" : null;
|
||||
formMethods.setValue("lockedTimeZone", lockedTimeZone, { shouldDirty: true });
|
||||
}}
|
||||
data-testid="lock-timezone-toggle"
|
||||
childrenClassName="lg:ml-0">
|
||||
{showSelector && (
|
||||
<div className="border-subtle flex flex-col gap-6 rounded-b-lg border border-t-0 p-6">
|
||||
<div>
|
||||
<Controller
|
||||
name="lockedTimeZone"
|
||||
control={formMethods.control}
|
||||
render={({ field: { value } }) => (
|
||||
<>
|
||||
<Label className="text-default mb-2 block text-sm font-medium">
|
||||
<>{t("timezone")}</>
|
||||
</Label>
|
||||
<TimezoneSelect
|
||||
id="lockedTimeZone"
|
||||
value={value ?? "Europe/London"}
|
||||
onChange={(event) => {
|
||||
if (event)
|
||||
formMethods.setValue("lockedTimeZone", event.value, { shouldDirty: true });
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</SettingsToggle>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<Controller
|
||||
name="allowReschedulingPastBookings"
|
||||
|
||||
@@ -68,6 +68,7 @@ export const getPublicEventSelect = (fetchAllUsers: boolean) => {
|
||||
disableGuests: true,
|
||||
metadata: true,
|
||||
lockTimeZoneToggleOnBookingPage: true,
|
||||
lockedTimeZone: true,
|
||||
requiresConfirmation: true,
|
||||
autoTranslateDescriptionEnabled: true,
|
||||
fieldTranslations: {
|
||||
|
||||
@@ -88,6 +88,7 @@ export type FormValues = {
|
||||
description: string;
|
||||
disableGuests: boolean;
|
||||
lockTimeZoneToggleOnBookingPage: boolean;
|
||||
lockedTimeZone: string | null;
|
||||
requiresConfirmation: boolean;
|
||||
requiresConfirmationWillBlockSlot: boolean;
|
||||
requiresConfirmationForFreeEmail: boolean;
|
||||
|
||||
Reference in new issue
Block a user