Skip to content

Scheduling infrastructure for absolutely everyone.

Not allowing random duration (#6743)

Leo Giovanetti376b693d91ee
diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx
index 6ebf471179e..08e7922710c 100644
--- a/apps/web/components/booking/pages/AvailabilityPage.tsx
+++ b/apps/web/components/booking/pages/AvailabilityPage.tsx
@@ -27,6 +27,7 @@ import notEmpty from "@calcom/lib/notEmpty";
import { getRecurringFreq } from "@calcom/lib/recurringStrings";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
import { detectBrowserTimeFormat, setIs24hClockInLocalStorage, TimeFormat } from "@calcom/lib/timeFormat";
+import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import { trpc } from "@calcom/trpc/react";
import { HeadSeo } from "@calcom/ui";
import { FiChevronDown, FiChevronUp, FiCreditCard, FiGlobe, FiRefreshCcw } from "@calcom/ui/components/icon";
@@ -98,7 +99,10 @@ const SlotPicker = ({
weekStart = 0,
ethSignature,
}: {
- eventType: Pick<EventType, "id" | "schedulingType" | "slug">;
+ eventType: Pick<
+ EventType & { metadata: z.infer<typeof EventTypeMetaDataSchema> },
+ "id" | "schedulingType" | "slug" | "length" | "metadata"
+ >;
timeFormat: TimeFormat;
onTimeFormatChange: (is24Hour: boolean) => void;
timeZone?: string;
@@ -110,11 +114,15 @@ const SlotPicker = ({
}) => {
const [selectedDate, setSelectedDate] = useState<Dayjs>();
const [browsingDate, setBrowsingDate] = useState<Dayjs>();
- const { duration } = useRouterQuery("duration");
+ let { duration = eventType.length.toString() } = useRouterQuery("duration");
const { date, setQuery: setDate } = useRouterQuery("date");
const { month, setQuery: setMonth } = useRouterQuery("month");
const router = useRouter();
+ if (!eventType.metadata?.multipleDuration) {
+ duration = eventType.length.toString();
+ }
+
const [slotPickerRef] = useAutoAnimate<HTMLDivElement>();
useEffect(() => {
diff --git a/apps/web/components/booking/pages/BookingPage.tsx b/apps/web/components/booking/pages/BookingPage.tsx
index 17fbba2e8de..fcd30b24e9c 100644
--- a/apps/web/components/booking/pages/BookingPage.tsx
+++ b/apps/web/components/booking/pages/BookingPage.tsx
@@ -125,7 +125,12 @@ const BookingPage = ({
const stripeAppData = getStripeAppData(eventType);
// Define duration now that we support multiple duration eventTypes
let duration = eventType.length;
- if (queryDuration && !isNaN(Number(queryDuration))) {
+ if (
+ queryDuration &&
+ !isNaN(Number(queryDuration)) &&
+ eventType.metadata?.multipleDuration &&
+ eventType.metadata?.multipleDuration.includes(Number(queryDuration))
+ ) {
duration = Number(queryDuration);
}