From 97f213f260e865cbb550253dd341a11ab772ff5e Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Fri, 20 Sep 2024 16:01:49 +0100 Subject: [PATCH] revert: be7d45afe232b52445a81a0ee70319e9243552b2 (#16742) --- .../schedules/components/Schedule.tsx | 46 ++----------------- .../availability/AvailabilitySettings.tsx | 17 +------ 2 files changed, 5 insertions(+), 58 deletions(-) diff --git a/packages/features/schedules/components/Schedule.tsx b/packages/features/schedules/components/Schedule.tsx index 861938e119..ddf55313ab 100644 --- a/packages/features/schedules/components/Schedule.tsx +++ b/packages/features/schedules/components/Schedule.tsx @@ -12,7 +12,6 @@ import type { import { Controller, useFieldArray, useFormContext } from "react-hook-form"; import type { GroupBase, Props } from "react-select"; -import type { AvailabilityFormValues } from "@calcom/atoms/availability/types"; import type { ConfigType } from "@calcom/dayjs"; import dayjs from "@calcom/dayjs"; import { defaultDayRange as DEFAULT_DAY_RANGE } from "@calcom/lib/availability"; @@ -48,7 +47,6 @@ export const ScheduleDay = ({ name, weekday, control, - handleSubmit, CopyButton, disabled, labels, @@ -58,7 +56,6 @@ export const ScheduleDay = ({ name: ArrayPath; weekday: string; control: Control; - handleSubmit?: (data: AvailabilityFormValues) => Promise; CopyButton: JSX.Element; disabled?: boolean; labels?: ScheduleLabelsType; @@ -71,7 +68,7 @@ export const ScheduleDay = ({ scheduleContainer?: string; }; }) => { - const { watch, setValue, getValues } = useFormContext(); + const { watch, setValue } = useFormContext(); const watchDayRange = watch(name); return ( @@ -97,7 +94,6 @@ export const ScheduleDay = ({ data-testid={`${weekday}-switch`} onCheckedChange={(isChecked) => { setValue(name, (isChecked ? [DEFAULT_DAY_RANGE] : []) as TFieldValues[typeof name]); - handleSubmit && handleSubmit(getValues() as AvailabilityFormValues); }} /> @@ -115,7 +111,6 @@ export const ScheduleDay = ({ control={control} name={name} disabled={disabled} - handleSubmit={handleSubmit} className={{ dayRanges: className?.dayRanges, timeRangeField: className?.timeRangeField, @@ -133,12 +128,10 @@ const CopyButton = ({ getValuesFromDayRange, weekStart, labels, - handleSubmit, }: { getValuesFromDayRange: string; weekStart: number; labels?: ScheduleLabelsType; - handleSubmit?: (data: AvailabilityFormValues) => Promise; }) => { const { t } = useLocale(); const [open, setOpen] = useState(false); @@ -167,7 +160,6 @@ const CopyButton = ({ onClick={(selected) => { selected.forEach((day) => setValue(`${fieldArrayName}.${day}`, getValues(getValuesFromDayRange))); setOpen(false); - handleSubmit && handleSubmit(getValues() as AvailabilityFormValues); }} onCancel={() => setOpen(false)} /> @@ -184,7 +176,6 @@ const Schedule = < control: Control; weekStart?: number; disabled?: boolean; - handleSubmit?: (data: AvailabilityFormValues) => Promise; labels?: ScheduleLabelsType; userTimeFormat?: number | null; }) => { @@ -200,7 +191,6 @@ export const ScheduleComponent = < >({ name, control, - handleSubmit, disabled, weekStart = 0, labels, @@ -209,7 +199,6 @@ export const ScheduleComponent = < }: { name: TPath; control: Control; - handleSubmit?: (data: AvailabilityFormValues) => Promise; weekStart?: number; disabled?: boolean; labels?: ScheduleLabelsType; @@ -245,14 +234,8 @@ export const ScheduleComponent = < key={weekday} weekday={weekday} control={control} - handleSubmit={handleSubmit} CopyButton={ - + } /> ); @@ -268,7 +251,6 @@ export const DayRanges = ({ labels, userTimeFormat, className, - handleSubmit, }: { name: ArrayPath; control?: Control; @@ -279,7 +261,6 @@ export const DayRanges = ({ dayRanges?: string; timeRangeField?: string; }; - handleSubmit?: (data: AvailabilityFormValues) => Promise; }) => { const { t } = useLocale(); const { getValues } = useFormContext(); @@ -302,7 +283,6 @@ export const DayRanges = ({ )} @@ -326,23 +306,16 @@ export const DayRanges = ({ if (slotRange?.append) { append(slotRange.append); - handleSubmit && handleSubmit(getValues() as AvailabilityFormValues); } if (slotRange?.prepend) { prepend(slotRange.prepend); - handleSubmit && handleSubmit(getValues() as AvailabilityFormValues); } }} /> )} {index !== 0 && ( - + )} @@ -357,17 +330,14 @@ const RemoveTimeButton = ({ disabled, className, labels, - handleSubmit, }: { index: number | number[]; remove: UseFieldArrayRemove; className?: string; disabled?: boolean; labels?: ScheduleLabelsType; - handleSubmit?: (data: AvailabilityFormValues) => Promise; }) => { const { t } = useLocale(); - const { getValues } = useFormContext(); return (