diff --git a/apps/web/components/v2/eventtype/EventLimitsTab.tsx b/apps/web/components/v2/eventtype/EventLimitsTab.tsx index f2fa69bf3f..e818c92187 100644 --- a/apps/web/components/v2/eventtype/EventLimitsTab.tsx +++ b/apps/web/components/v2/eventtype/EventLimitsTab.tsx @@ -9,7 +9,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; import { PeriodType } from "@calcom/prisma/client"; import type { BookingLimit } from "@calcom/types/Calendar"; import { Icon } from "@calcom/ui"; -import { Select, Switch, Label, Input, MinutesField, Button } from "@calcom/ui/v2"; +import { Select, Switch, Label, Input, DurationField, Button } from "@calcom/ui/v2"; import DateRangePicker from "@calcom/ui/v2/core/form/date-range-picker/DateRangePicker"; export const EventLimitsTab = (props: Pick) => { @@ -45,6 +45,8 @@ export const EventLimitsTab = (props: Pick) defaultValue: periodType?.type, }); + const durationArray = [eventType.minimumBookingNoticeType]; + return (
@@ -114,13 +116,94 @@ export const EventLimitsTab = (props: Pick)
-
- + { + const minBookingValue = formMethods.watch("minimumBookingNotice"); + let newMinBookingValue: number; + const convertToNewDurationType = function ( + prevType: string, + newType: string, + prevValue: number + ) { + console.log(prevType, newType, prevValue); + if (!prevType) { + prevType = eventType.minimumBookingNoticeType; + } + if (newType == "mins") { + if (prevType == "hours") { + newMinBookingValue = prevValue * 60; + } + if (prevType == "calendar days") { + newMinBookingValue = prevValue * 1440; + } + } else if (newType == "hours") { + if (prevType == "mins") { + newMinBookingValue = prevValue / 60; + } + if (prevType == "calendar days") { + newMinBookingValue = prevValue * 24; + } + } else if (newType == "calendar days") { + if (prevType == "mins") { + newMinBookingValue = prevValue / 1440; + } + if (prevType == "hours") { + newMinBookingValue = prevValue / 24; + } + } else if (newType == prevType) { + newMinBookingValue = prevValue; + } + }; + + const durationTypeOptions = [ + { + label: t("minutes"), + value: "mins", + }, + { + label: t("hours"), + value: "hours", + }, + { + label: t("calendar_days"), + value: "calendar days", + }, + ]; + + return ( + <> + +