diff --git a/apps/web/components/booking/BookingDescription.tsx b/apps/web/components/booking/BookingDescription.tsx
index cacdb59359..6e9b2bcc6e 100644
--- a/apps/web/components/booking/BookingDescription.tsx
+++ b/apps/web/components/booking/BookingDescription.tsx
@@ -1,9 +1,11 @@
import { SchedulingType } from "@prisma/client";
-import { FC, ReactNode } from "react";
+import { FC, ReactNode, useEffect } from "react";
import { classNames } from "@calcom/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { Icon } from "@calcom/ui";
+import { Icon, Badge } from "@calcom/ui";
+
+import useRouterQuery from "@lib/hooks/useRouterQuery";
import { UserAvatars } from "@components/booking/UserAvatars";
import EventTypeDescriptionSafeHTML from "@components/eventtype/EventTypeDescriptionSafeHTML";
@@ -40,6 +42,18 @@ interface Props {
const BookingDescription: FC = (props) => {
const { profile, eventType, isBookingPage = false, children } = props;
const { t } = useLocale();
+ const { duration, setQuery: setDuration } = useRouterQuery("duration");
+ useEffect(() => {
+ if (eventType.metadata?.multipleDuration !== undefined) {
+ if (!duration) {
+ setDuration(eventType.length);
+ } else {
+ if (!eventType.metadata?.multipleDuration.includes(Number(duration))) {
+ setDuration(eventType.length);
+ }
+ }
+ }
+ }, []);
return (
<>
= (props) => {
-
-
- {eventType.length} {t("minutes")}
-
+
+ {eventType.metadata?.multipleDuration !== undefined ? (
+ !isBookingPage ? (
+
+ {eventType.metadata.multipleDuration.map((dur, idx) => (
+ -
+ {
+ setDuration(dur);
+ }}>
+ {dur} {t("minute_timeUnit")}
+
+
+ ))}
+
+ ) : (
+ `${duration} ${t("minutes")}`
+ )
+ ) : (
+ `${eventType.length} ${t("minutes")}`
+ )}
+
{children}
>
diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx
index d0d6f348e7..fa1b1871f9 100644
--- a/apps/web/components/booking/pages/AvailabilityPage.tsx
+++ b/apps/web/components/booking/pages/AvailabilityPage.tsx
@@ -27,12 +27,14 @@ 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 { Icon, DatePicker } from "@calcom/ui";
import { timeZone as localStorageTimeZone } from "@lib/clock";
// import { timeZone } from "@lib/clock";
import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally";
+import useRouterQuery from "@lib/hooks/useRouterQuery";
import { isBrandingHidden } from "@lib/isBrandingHidden";
import Gates, { Gate, GateState } from "@components/Gates";
@@ -70,6 +72,7 @@ const useSlots = ({
endTime,
usernameList,
timeZone,
+ duration,
}: {
eventTypeId: number;
eventTypeSlug: string;
@@ -77,6 +80,7 @@ const useSlots = ({
endTime?: Dayjs;
usernameList: string[];
timeZone?: string;
+ duration?: string;
}) => {
const { data, isLoading, isPaused } = trpc.viewer.public.slots.getSchedule.useQuery(
{
@@ -86,6 +90,7 @@ const useSlots = ({
startTime: startTime?.toISOString() || "",
endTime: endTime?.toISOString() || "",
timeZone,
+ duration,
},
{
enabled: !!startTime && !!endTime,
@@ -126,6 +131,7 @@ const SlotPicker = ({
}) => {
const [selectedDate, setSelectedDate] = useState();
const [browsingDate, setBrowsingDate] = useState();
+ const { duration } = useRouterQuery("duration");
const { date, setQuery: setDate } = useRouterQuery("date");
const { month, setQuery: setMonth } = useRouterQuery("month");
const router = useRouter();
@@ -151,7 +157,7 @@ const SlotPicker = ({
setSelectedDate(dayjs.tz(date, timeZone));
}
}
- }, [router.isReady, month, date, timeZone]);
+ }, [router.isReady, month, date, duration, timeZone]);
const { i18n, isLocaleReady } = useLocale();
const { slots: _1 } = useSlots({
@@ -161,6 +167,7 @@ const SlotPicker = ({
startTime: selectedDate?.startOf("day"),
endTime: selectedDate?.endOf("day"),
timeZone,
+ duration,
});
const { slots: _2, isLoading } = useSlots({
eventTypeId: eventType.id,
@@ -169,6 +176,7 @@ const SlotPicker = ({
startTime: browsingDate?.startOf("month"),
endTime: browsingDate?.endOf("month"),
timeZone,
+ duration,
});
const slots = useMemo(() => ({ ..._2, ..._1 }), [_1, _2]);
@@ -230,13 +238,13 @@ function TimezoneDropdown({
return (
-
-
+
+
{timeZone}
{isTimeOptionsOpen ? (
-
+
) : (
-
+
)}
@@ -258,23 +266,6 @@ const dateQuerySchema = z.object({
timeZone: z.string().optional().default(""),
});
-const useRouterQuery = (name: T) => {
- const router = useRouter();
- const existingQueryParams = router.asPath.split("?")[1];
-
- const urlParams = new URLSearchParams(existingQueryParams);
- const query = Object.fromEntries(urlParams);
-
- const setQuery = (newValue: string | number | null | undefined) => {
- router.replace({ query: { ...router.query, [name]: newValue } }, undefined, { shallow: true });
- router.replace({ query: { ...router.query, ...query, [name]: newValue } }, undefined, { shallow: true });
- };
-
- return { [name]: query[name], setQuery } as {
- [K in T]: string | undefined;
- } & { setQuery: typeof setQuery };
-};
-
export type Props = AvailabilityTeamPageProps | AvailabilityPageProps | DynamicAvailabilityPageProps;
const AvailabilityPage = ({ profile, eventType, ...restProps }: Props) => {
diff --git a/apps/web/components/booking/pages/BookingPage.tsx b/apps/web/components/booking/pages/BookingPage.tsx
index 49744232aa..5404f51b55 100644
--- a/apps/web/components/booking/pages/BookingPage.tsx
+++ b/apps/web/components/booking/pages/BookingPage.tsx
@@ -43,6 +43,7 @@ import { asStringOrNull } from "@lib/asStringOrNull";
import { timeZone } from "@lib/clock";
import { ensureArray } from "@lib/ensureArray";
import useMeQuery from "@lib/hooks/useMeQuery";
+import useRouterQuery from "@lib/hooks/useRouterQuery";
import createBooking from "@lib/mutations/bookings/create-booking";
import createRecurringBooking from "@lib/mutations/bookings/create-recurring-booking";
import { parseDate, parseRecurringDates } from "@lib/parseDate";
@@ -85,9 +86,7 @@ const BookingPage = ({
...restProps
}: BookingPageProps) => {
const { t, i18n } = useLocale();
- // Get user so we can determine 12/24 hour format preferences
- const query = useMeQuery();
- const user = query.data;
+ const { duration: queryDuration } = useRouterQuery("duration");
const isEmbed = useIsEmbed(restProps.isEmbed);
const shouldAlignCentrallyInEmbed = useEmbedNonStylesConfig("align") !== "left";
const shouldAlignCentrally = !isEmbed || shouldAlignCentrallyInEmbed;
@@ -104,6 +103,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))) {
+ duration = Number(queryDuration);
+ }
+
useEffect(() => {
if (top !== window) {
//page_view will be collected automatically by _middleware.ts
@@ -318,7 +323,7 @@ const BookingPage = ({
const recurringBookings = recurringDates.map((recurringDate) => ({
...booking,
start: dayjs(recurringDate).format(),
- end: dayjs(recurringDate).add(eventType.length, "minute").format(),
+ end: dayjs(recurringDate).add(duration, "minute").format(),
eventTypeId: eventType.id,
eventTypeSlug: eventType.slug,
recurringEventId,
@@ -351,7 +356,7 @@ const BookingPage = ({
mutation.mutate({
...booking,
start: dayjs(date).format(),
- end: dayjs(date).add(eventType.length, "minute").format(),
+ end: dayjs(date).add(duration, "minute").format(),
eventTypeId: eventType.id,
eventTypeSlug: eventType.slug,
timeZone: timeZone(),
@@ -839,7 +844,7 @@ const BookingPage = ({
) : (
)}
- -
-
- {eventType.length}m
-
-
+ {eventType.metadata?.multipleDuration ? (
+ eventType.metadata.multipleDuration.map((dur, idx) => (
+ -
+
+ {dur}m
+
+
+ ))
+ ) : (
+ -
+
+ {eventType.length}m
+
+
+ )}
{eventType.schedulingType ? (
-