Scheduling infrastructure for absolutely everyone.
unlock all fields in limits tab (#11936)
Carina Wollendorfer7a014761dc3b
diff --git a/apps/web/components/eventtype/EventLimitsTab.tsx b/apps/web/components/eventtype/EventLimitsTab.tsxindex 1c911876779..24502bb2b87 100644--- a/apps/web/components/eventtype/EventLimitsTab.tsx+++ b/apps/web/components/eventtype/EventLimitsTab.tsx@@ -7,7 +7,6 @@ import type { UseFormRegisterReturn } from "react-hook-form";import { Controller, useFormContext, useWatch } from "react-hook-form";import type { SingleValue } from "react-select";-import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";import { classNames } from "@calcom/lib";import type { DurationType } from "@calcom/lib/convertToNewDurationType";import convertToNewDurationType from "@calcom/lib/convertToNewDurationType";@@ -141,17 +140,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTydefaultValue: periodType?.type,});- const { shouldLockIndicator, shouldLockDisableProps } = useLockedFieldsManager(- eventType,- t("locked_fields_admin_description"),- t("locked_fields_member_description")- );-- const bookingLimitsLocked = shouldLockDisableProps("bookingLimits");- const durationLimitsLocked = shouldLockDisableProps("durationLimits");- const periodTypeLocked = shouldLockDisableProps("periodType");- const offsetStartLockedProps = shouldLockDisableProps("offsetStart");-const optionsPeriod = [{ value: 1, label: t("calendar_days") },{ value: 0, label: t("business_days") },@@ -174,10 +162,7 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTy<div className="border-subtle space-y-6 rounded-lg border p-6"><div className="flex flex-col space-y-4 lg:flex-row lg:space-x-4 lg:space-y-0"><div className="w-full">- <Label htmlFor="beforeBufferTime">- {t("before_event")}- {shouldLockIndicator("bookingLimits")}- </Label>+ <Label htmlFor="beforeBufferTime">{t("before_event")}</Label><Controllername="beforeBufferTime"control={formMethods.control}@@ -196,7 +181,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTyreturn (<SelectisSearchable={false}- isDisabled={shouldLockDisableProps("bookingLimits").disabled}onChange={(val) => {if (val) onChange(val.value);}}@@ -210,10 +194,7 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTy/></div><div className="w-full">- <Label htmlFor="afterBufferTime">- {t("after_event")}- {shouldLockIndicator("bookingLimits")}- </Label>+ <Label htmlFor="afterBufferTime">{t("after_event")}</Label><Controllername="afterBufferTime"control={formMethods.control}@@ -232,7 +213,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTyreturn (<SelectisSearchable={false}- isDisabled={shouldLockDisableProps("bookingLimits").disabled}onChange={(val) => {if (val) onChange(val.value);}}@@ -248,20 +228,11 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTy</div><div className="flex flex-col space-y-4 lg:flex-row lg:space-x-4 lg:space-y-0"><div className="w-full">- <Label htmlFor="minimumBookingNotice">- {t("minimum_booking_notice")}- {shouldLockIndicator("minimumBookingNotice")}- </Label>- <MinimumBookingNoticeInput- disabled={shouldLockDisableProps("minimumBookingNotice").disabled}- {...formMethods.register("minimumBookingNotice")}- />+ <Label htmlFor="minimumBookingNotice">{t("minimum_booking_notice")}</Label>+ <MinimumBookingNoticeInput {...formMethods.register("minimumBookingNotice")} /></div><div className="w-full">- <Label htmlFor="slotInterval">- {t("slot_interval")}- {shouldLockIndicator("slotInterval")}- </Label>+ <Label htmlFor="slotInterval">{t("slot_interval")}</Label><Controllername="slotInterval"control={formMethods.control}@@ -279,7 +250,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTyreturn (<SelectisSearchable={false}- isDisabled={shouldLockDisableProps("slotInterval").disabled}onChange={(val) => {formMethods.setValue("slotInterval", val && (val.value || 0) > 0 ? val.value : null);}}@@ -305,7 +275,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTytoggleSwitchAtTheEnd={true}labelClassName="text-sm"title={t("limit_booking_frequency")}- {...bookingLimitsLocked}description={t("limit_booking_frequency_description")}checked={isChecked}onCheckedChange={(active) => {@@ -323,12 +292,7 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTy)}childrenClassName="lg:ml-0"><div className="border-subtle rounded-b-lg border border-t-0 p-6">- <IntervalLimitsManager- disabled={bookingLimitsLocked.disabled}- propertyName="bookingLimits"- defaultLimit={1}- step={1}- />+ <IntervalLimitsManager propertyName="bookingLimits" defaultLimit={1} step={1} /></div></SettingsToggle>);@@ -350,7 +314,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTychildrenClassName="lg:ml-0"title={t("limit_total_booking_duration")}description={t("limit_total_booking_duration_description")}- {...durationLimitsLocked}checked={isChecked}onCheckedChange={(active) => {if (active) {@@ -365,7 +328,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTy<IntervalLimitsManagerpropertyName="durationLimits"defaultLimit={60}- disabled={durationLimitsLocked.disabled}step={15}textFieldSuffix={t("minutes")}/>@@ -391,7 +353,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTychildrenClassName="lg:ml-0"title={t("limit_future_bookings")}description={t("limit_future_bookings_description")}- {...periodTypeLocked}checked={isChecked}onCheckedChange={(bool) => formMethods.setValue("periodType", bool ? "ROLLING" : "UNLIMITED")}><div className="border-subtle rounded-b-lg border border-t-0 p-6">@@ -399,9 +360,7 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTydefaultValue={watchPeriodType}value={watchPeriodType}onValueChange={(val) => formMethods.setValue("periodType", val as PeriodType)}>- {PERIOD_TYPES.filter((opt) =>- periodTypeLocked.disabled ? watchPeriodType === opt.type : true- ).map((period) => {+ {PERIOD_TYPES.map((period) => {if (period.type === "UNLIMITED") return null;return (<div@@ -410,14 +369,13 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTywatchPeriodType === "UNLIMITED" && "pointer-events-none opacity-30")}key={period.type}>- {!periodTypeLocked.disabled && (- <RadioGroup.Item- id={period.type}- value={period.type}- className="min-w-4 bg-default border-default flex h-4 w-4 cursor-pointer items-center rounded-full border focus:border-2 focus:outline-none ltr:mr-2 rtl:ml-2">- <RadioGroup.Indicator className="after:bg-inverted relative flex h-4 w-4 items-center justify-center after:block after:h-2 after:w-2 after:rounded-full" />- </RadioGroup.Item>- )}+ <RadioGroup.Item+ id={period.type}+ value={period.type}+ className="min-w-4 bg-default border-default flex h-4 w-4 cursor-pointer items-center rounded-full border focus:border-2 focus:outline-none ltr:mr-2 rtl:ml-2">+ <RadioGroup.Indicator className="after:bg-inverted relative flex h-4 w-4 items-center justify-center after:block after:h-2 after:w-2 after:rounded-full" />+ </RadioGroup.Item>+{period.prefix ? <span>{period.prefix} </span> : null}{period.type === "ROLLING" && (<div className="flex items-center">@@ -426,14 +384,12 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTytype="number"className="border-default my-0 block w-16 text-sm [appearance:textfield] ltr:mr-2 rtl:ml-2"placeholder="30"- disabled={periodTypeLocked.disabled}{...formMethods.register("periodDays", { valueAsNumber: true })}defaultValue={eventType.periodDays || 30}/><Selectoptions={optionsPeriod}isSearchable={false}- isDisabled={periodTypeLocked.disabled}onChange={(opt) => {formMethods.setValue("periodCountCalendarDays",@@ -458,7 +414,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTy<DateRangePickerstartDate={formMethods.getValues("periodDates").startDate}endDate={formMethods.getValues("periodDates").endDate}- disabled={periodTypeLocked.disabled}onDatesChange={({ startDate, endDate }) => {formMethods.setValue("periodDates", {startDate,@@ -490,7 +445,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTychildrenClassName="lg:ml-0"title={t("offset_toggle")}description={t("offset_toggle_description")}- {...offsetStartLockedProps}checked={offsetToggle}onCheckedChange={(active) => {setOffsetToggle(active);@@ -503,7 +457,6 @@ export const EventLimitsTab = ({ eventType }: Pick<EventTypeSetupProps, "eventTyrequiredtype="number"containerClassName="max-w-80"- {...offsetStartLockedProps}label={t("offset_start")}{...formMethods.register("offsetStart")}addOnSuffix={<>{t("minutes")}</>}