Scheduling infrastructure for absolutely everyone.
Allow clients to choose different duration for a meeting (#5660)
Leo Giovanetti26d675e16264
diff --git a/apps/web/components/booking/BookingDescription.tsx b/apps/web/components/booking/BookingDescription.tsxindex cacdb593592..6e9b2bcc6ec 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> = (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 (<><UserAvatars@@ -90,14 +104,46 @@ const BookingDescription: FC<Props> = (props) => {<AvailableEventLocationslocations={eventType.locations as AvailabilityPageProps["eventType"]["locations"]}/>- <p+ <divclassName={classNames(- "text-sm font-medium",+ "flex flex-nowrap text-sm font-medium",isBookingPage && "dark:text-darkgray-600 text-gray-600")}>- <Icon.FiClock className="mr-[10px] -mt-1 ml-[2px] inline-block h-4 w-4" />- {eventType.length} {t("minutes")}- </p>+ <Icon.FiClock+ className={classNames(+ "min-h-4 min-w-4 mr-[10px] ml-[2px] inline-block",+ isBookingPage && "mt-[2px]"+ )}+ />+ {eventType.metadata?.multipleDuration !== undefined ? (+ !isBookingPage ? (+ <ul className="-mt-1 flex flex-wrap gap-1">+ {eventType.metadata.multipleDuration.map((dur, idx) => (+ <li key={idx}>+ <Badge+ variant="gray"+ size="lg"+ className={classNames(+ duration === dur.toString()+ ? "bg-darkgray-200 text-darkgray-900 dark:bg-darkmodebrand dark:!text-darkmodebrandcontrast"+ : "hover:bg-darkgray-200 dark:hover:bg-darkmodebrand hover:text-darkgray-900 dark:hover:text-darkmodebrandcontrast dark:bg-darkgray-200 bg-gray-200 text-gray-900 dark:text-white",+ "cursor-pointer"+ )}+ onClick={() => {+ setDuration(dur);+ }}>+ {dur} {t("minute_timeUnit")}+ </Badge>+ </li>+ ))}+ </ul>+ ) : (+ `${duration} ${t("minutes")}`+ )+ ) : (+ `${eventType.length} ${t("minutes")}`+ )}+ </div>{children}</div></>diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsxindex d0d6f348e79..fa1b1871f92 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<Dayjs>();const [browsingDate, setBrowsingDate] = useState<Dayjs>();+ 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 (<Popover.Root open={isTimeOptionsOpen} onOpenChange={setIsTimeOptionsOpen}><Popover.Trigger className="min-w-32 dark:text-darkgray-600 radix-state-open:bg-gray-200 dark:radix-state-open:bg-darkgray-200 group relative mb-2 -ml-2 inline-block rounded-md px-2 py-2 text-left text-gray-600">- <p className="text-sm font-medium">- <Icon.FiGlobe className="mr-[10px] ml-[2px] -mt-[2px] inline-block h-4 w-4" />+ <p className="flex items-center text-sm font-medium">+ <Icon.FiGlobe className="min-h-4 min-w-4 mr-[10px] ml-[2px] -mt-[2px] inline-block" />{timeZone}{isTimeOptionsOpen ? (- <Icon.FiChevronUp className="ml-1 inline-block h-4 w-4" />+ <Icon.FiChevronUp className="min-h-4 min-w-4 ml-1 inline-block" />) : (- <Icon.FiChevronDown className="ml-1 inline-block h-4 w-4" />+ <Icon.FiChevronDown className="min-h-4 min-w-4 ml-1 inline-block" />)}</p></Popover.Trigger>@@ -258,23 +266,6 @@ const dateQuerySchema = z.object({timeZone: z.string().optional().default(""),});-const useRouterQuery = <T extends string>(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.tsxindex 49744232aa3..5404f51b556 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 = ({) : (<textarea{...bookingForm.register("notes")}- required={!!eventType.metadata.additionalNotesRequired}+ required={!!eventType.metadata?.additionalNotesRequired}id="notes"name="notes"rows={3}diff --git a/apps/web/components/eventtype/EventSetupTab.tsx b/apps/web/components/eventtype/EventSetupTab.tsxindex c5420098a89..06181f68dd9 100644--- a/apps/web/components/eventtype/EventSetupTab.tsx+++ b/apps/web/components/eventtype/EventSetupTab.tsx@@ -4,12 +4,13 @@ import { isValidPhoneNumber } from "libphonenumber-js";import { EventTypeSetupInfered, FormValues } from "pages/event-types/[type]";import { useState } from "react";import { Controller, useForm, useFormContext } from "react-hook-form";+import { MultiValue } from "react-select";import { z } from "zod";import { EventLocationType, getEventLocationType } from "@calcom/app-store/locations";import { CAL_URL } from "@calcom/lib/constants";import { useLocale } from "@calcom/lib/hooks/useLocale";-import { Button, Icon, Label, Select, Skeleton, TextField } from "@calcom/ui";+import { Button, Icon, Label, Select, Skeleton, TextField, SettingsToggle } from "@calcom/ui";import { slugify } from "@lib/slugify";@@ -30,6 +31,34 @@ export const EventSetupTab = (const [showLocationModal, setShowLocationModal] = useState(false);const [editingLocationType, setEditingLocationType] = useState<string>("");const [selectedLocation, setSelectedLocation] = useState<OptionTypeBase | undefined>(undefined);+ const [multipleDuration, setMultipleDuration] = useState(eventType.metadata.multipleDuration);++ const multipleDurationOptions = [+ { value: 5, label: t("multiple_duration_mins", { count: 5 }) },+ { value: 10, label: t("multiple_duration_mins", { count: 10 }) },+ { value: 15, label: t("multiple_duration_mins", { count: 15 }) },+ { value: 20, label: t("multiple_duration_mins", { count: 20 }) },+ { value: 25, label: t("multiple_duration_mins", { count: 25 }) },+ { value: 30, label: t("multiple_duration_mins", { count: 30 }) },+ { value: 45, label: t("multiple_duration_mins", { count: 45 }) },+ { value: 50, label: t("multiple_duration_mins", { count: 50 }) },+ { value: 60, label: t("multiple_duration_mins", { count: 60 }) },+ { value: 75, label: t("multiple_duration_mins", { count: 75 }) },+ { value: 80, label: t("multiple_duration_mins", { count: 80 }) },+ { value: 90, label: t("multiple_duration_mins", { count: 90 }) },+ { value: 120, label: t("multiple_duration_mins", { count: 120 }) },+ { value: 180, label: t("multiple_duration_mins", { count: 180 }) },+ ];++ const [selectedMultipleDuration, setSelectedMultipleDuration] = useState<+ MultiValue<{+ value: number;+ label: string;+ }>+ >(multipleDurationOptions.filter((mdOpt) => multipleDuration?.includes(mdOpt.value)));+ const [defaultDuration, setDefaultDuration] = useState(+ selectedMultipleDuration.find((opt) => opt.value === eventType.length) ?? null+ );const openLocationModal = (type: EventLocationType["type"]) => {setSelectedLocation(locationOptions.find((option) => option.value === type));@@ -219,17 +248,91 @@ export const EventSetupTab = (setValueAs: (v) => slugify(v),})}/>- <TextField- required- name="length"- type="number"- label={t("duration")}- addOnSuffix={<>{t("minutes")}</>}- defaultValue={eventType.length ?? 15}- onChange={(e) => {- formMethods.setValue("length", Number(e.target.value));- }}- />+ {multipleDuration ? (+ <div className="space-y-4">+ <div>+ <Skeleton as={Label} loadingClassName="w-16">+ {t("available_durations")}+ </Skeleton>+ <Select+ isMulti+ defaultValue={selectedMultipleDuration}+ name="metadata.multipleDuration"+ isSearchable={false}+ className="h-auto !min-h-[36px] text-sm"+ options={multipleDurationOptions}+ onChange={(options) => {+ const values = options+ .map((opt) => opt.value)+ .sort(function (a, b) {+ return a - b;+ });+ setMultipleDuration(values);+ setSelectedMultipleDuration(options);+ if (!options.find((opt) => opt.value === defaultDuration?.value)) {+ if (options.length > 0) {+ setDefaultDuration(options[0]);+ } else {+ setDefaultDuration(null);+ }+ }+ if (options.length === 1 && defaultDuration === null) {+ setDefaultDuration(options[0]);+ }+ formMethods.setValue("metadata.multipleDuration", values);+ }}+ />+ </div>+ <div>+ <Skeleton as={Label} loadingClassName="w-16">+ {t("default_duration")}+ </Skeleton>+ <Select+ value={defaultDuration}+ isSearchable={false}+ name="length"+ className="text-sm"+ noOptionsMessage={() => t("default_duration_no_options")}+ options={selectedMultipleDuration}+ onChange={(option) => {+ setDefaultDuration(+ selectedMultipleDuration.find((opt) => opt.value === option?.value) ?? null+ );+ formMethods.setValue("length", Number(option?.value));+ }}+ />+ </div>+ </div>+ ) : (+ <TextField+ required+ name="length"+ type="number"+ label={t("duration")}+ addOnSuffix={<>{t("minutes")}</>}+ defaultValue={eventType.length ?? 15}+ onChange={(e) => {+ formMethods.setValue("length", Number(e.target.value));+ }}+ />+ )}+ <div className="!mt-4 [&_label]:my-1 [&_label]:font-normal">+ <SettingsToggle+ title={t("allow_booker_to_select_duration")}+ checked={multipleDuration !== undefined}+ onCheckedChange={() => {+ if (multipleDuration !== undefined) {+ setMultipleDuration(undefined);+ formMethods.setValue("metadata.multipleDuration", undefined);+ formMethods.setValue("length", eventType.length);+ } else {+ setMultipleDuration([]);+ formMethods.setValue("metadata.multipleDuration", []);+ formMethods.setValue("length", 0);+ }+ }}+ />+ </div><div><Skeleton as={Label} loadingClassName="w-16">{t("location")}diff --git a/apps/web/lib/hooks/useRouterQuery.ts b/apps/web/lib/hooks/useRouterQuery.tsnew file mode 100644index 00000000000..155d991cd03--- /dev/null+++ b/apps/web/lib/hooks/useRouterQuery.ts@@ -0,0 +1,18 @@+import { useRouter } from "next/router";++export default function useRouterQuery<T extends string>(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 };+}diff --git a/apps/web/pages/[user]/[type].tsx b/apps/web/pages/[user]/[type].tsxindex 01102656e83..9e4c350b3f7 100644--- a/apps/web/pages/[user]/[type].tsx+++ b/apps/web/pages/[user]/[type].tsx@@ -224,7 +224,7 @@ async function getDynamicGroupPageProps(context: GetStaticPropsContext) {const locations = eventType.locations ? (eventType.locations as LocationObject[]) : [];const eventTypeObject = Object.assign({}, eventType, {- metadata: (eventType.metadata || {}) as JSONObject,+ metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}),recurringEvent: parseRecurringEvent(eventType.recurringEvent),locations: privacyFilteredLocations(locations),users: users.map((user) => {diff --git a/apps/web/pages/[user]/book.tsx b/apps/web/pages/[user]/book.tsxindex 36b353fb23d..7cccc1972f2 100644--- a/apps/web/pages/[user]/book.tsx+++ b/apps/web/pages/[user]/book.tsx@@ -12,6 +12,7 @@ import {import { useLocale } from "@calcom/lib/hooks/useLocale";import { bookEventTypeSelect } from "@calcom/prisma";import prisma from "@calcom/prisma";+import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";import { asStringOrNull, asStringOrThrow } from "@lib/asStringOrNull";import getBooking, { GetBookingType } from "@lib/getBooking";@@ -113,7 +114,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {const eventType = {...eventTypeRaw,- metadata: (eventTypeRaw.metadata || {}) as JSONObject,+ metadata: EventTypeMetaDataSchema.parse(eventTypeRaw.metadata || {}),recurringEvent: parseRecurringEvent(eventTypeRaw.recurringEvent),};diff --git a/apps/web/pages/d/[link]/book.tsx b/apps/web/pages/d/[link]/book.tsxindex 5cff841cdff..8add273c06b 100644--- a/apps/web/pages/d/[link]/book.tsx+++ b/apps/web/pages/d/[link]/book.tsx@@ -4,6 +4,7 @@ import { JSONObject } from "superjson/dist/types";import { parseRecurringEvent } from "@calcom/lib";import prisma from "@calcom/prisma";import { bookEventTypeSelect } from "@calcom/prisma/selects";+import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";import { asStringOrNull, asStringOrThrow } from "@lib/asStringOrNull";import { inferSSRProps } from "@lib/types/inferSSRProps";@@ -69,7 +70,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {if (!eventTypeRaw) return { notFound: true };const eventType = {...eventTypeRaw,- metadata: (eventTypeRaw.metadata || {}) as JSONObject,+ metadata: EventTypeMetaDataSchema.parse(eventTypeRaw.metadata || {}),recurringEvent: parseRecurringEvent(eventTypeRaw.recurringEvent),};diff --git a/apps/web/pages/event-types/[type]/index.tsx b/apps/web/pages/event-types/[type]/index.tsxindex 70de98159c9..70dbf87f3e6 100644--- a/apps/web/pages/event-types/[type]/index.tsx+++ b/apps/web/pages/event-types/[type]/index.tsx@@ -266,7 +266,17 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {if (bookingLimits) {const isValid = validateBookingLimitOrder(bookingLimits);- if (!isValid) throw new Error("Booking limits must be in accending order. [day,week,month,year]");+ if (!isValid) throw new Error(t("event_setup_booking_limits_error"));+ }++ if (metadata?.multipleDuration !== undefined) {+ if (metadata?.multipleDuration.length < 1) {+ throw new Error(t("event_setup_multiple_duration_error"));+ } else {+ if (!metadata?.multipleDuration?.includes(input.length)) {+ throw new Error(t("event_setup_multiple_duration_default_error"));+ }+ }}updateMutation.mutate({diff --git a/apps/web/pages/success.tsx b/apps/web/pages/success.tsxindex f834f966657..1e708d1853c 100644--- a/apps/web/pages/success.tsx+++ b/apps/web/pages/success.tsx@@ -189,6 +189,7 @@ export default function Success(props: SuccessProps) {const isEmbed = useIsEmbed();const shouldAlignCentrallyInEmbed = useEmbedNonStylesConfig("align") !== "left";const shouldAlignCentrally = !isEmbed || shouldAlignCentrallyInEmbed;+ const [calculatedDuration, setCalculatedDuration] = useState<number | undefined>(undefined);function setIsCancellationMode(value: boolean) {if (value) router.query.cancel = "true";@@ -231,7 +232,7 @@ export default function Success(props: SuccessProps) {sdkActionManager.fire("bookingSuccessful", {eventType,date: date.toString(),- duration: eventType.length,+ duration: calculatedDuration,organizer: {name: users[0].name || "Nameless",email: users[0].email || "Email-less",@@ -245,6 +246,12 @@ export default function Success(props: SuccessProps) {// eslint-disable-next-line react-hooks/exhaustive-deps}, [eventType, needsConfirmation]);+ useEffect(() => {+ setCalculatedDuration(+ dayjs(props.bookingInfo.endTime).diff(dayjs(props.bookingInfo.startTime), "minutes")+ );+ }, []);+function eventLink(): string {const optional: { location?: string } = {};if (location) {@@ -263,7 +270,9 @@ export default function Success(props: SuccessProps) {title: eventName,description: props.eventType.description ? props.eventType.description : undefined,/** formatted to required type of description ^ */- duration: { minutes: props.eventType.length },+ duration: {+ minutes: calculatedDuration,+ },...optional,});@@ -389,6 +398,7 @@ export default function Success(props: SuccessProps) {<div className="col-span-2 mb-6 last:mb-0"><RecurringBookingseventType={props.eventType}+ duration={calculatedDuration}recurringBookings={props.recurringBookings}allRemainingBookings={allRemainingBookings}date={date}@@ -513,114 +523,118 @@ export default function Success(props: SuccessProps) {/></>))}- {userIsOwner && !needsConfirmation && !isCancellationMode && !isCancelled && (- <>- <hr className="border-bookinglightest dark:border-darkgray-300 mt-8" />- <div className="text-bookingdark align-center flex flex-row justify-center pt-8">- <span className="flex self-center font-medium text-gray-700 ltr:mr-2 rtl:ml-2 dark:text-gray-50">- {t("add_to_calendar")}- </span>- <div className="justify-left mt-1 flex text-left sm:mt-0">- <Link- href={- `https://calendar.google.com/calendar/r/eventedit?dates=${date- .utc()- .format("YYYYMMDDTHHmmss[Z]")}/${date- .add(props.eventType.length, "minute")- .utc()- .format("YYYYMMDDTHHmmss[Z]")}&text=${eventName}&details=${- props.eventType.description- }` +- (typeof location === "string"- ? "&location=" + encodeURIComponent(location)- : "") +- (props.eventType.recurringEvent- ? "&recur=" +- encodeURIComponent(new RRule(props.eventType.recurringEvent).toString())- : "")- }>- <a className="mr-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white">- <svg- className="-mt-1.5 inline-block h-4 w-4"- fill="currentColor"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 24 24">- <title>Google</title>- <path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" />- </svg>- </a>- </Link>- <Link- href={- encodeURI(- "https://outlook.live.com/calendar/0/deeplink/compose?body=" +- props.eventType.description +- "&enddt=" +- date.add(props.eventType.length, "minute").utc().format() +- "&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=" +- date.utc().format() +- "&subject=" +- eventName- ) + (location ? "&location=" + location : "")- }>- <a- className="mx-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white"- target="_blank">- <svg- className="mr-1 -mt-1.5 inline-block h-4 w-4"- fill="currentColor"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 24 24">- <title>Microsoft Outlook</title>- <path d="M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V10.85l1.24.72h.01q.1.07.18.18.07.12.07.25zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.8v-2.73zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z" />- </svg>- </a>- </Link>- <Link- href={- encodeURI(- "https://outlook.office.com/calendar/0/deeplink/compose?body=" +- props.eventType.description +- "&enddt=" +- date.add(props.eventType.length, "minute").utc().format() +- "&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=" +- date.utc().format() +- "&subject=" +- eventName- ) + (location ? "&location=" + location : "")- }>- <a- className="mx-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white"- target="_blank">- <svg- className="mr-1 -mt-1.5 inline-block h-4 w-4"- fill="currentColor"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 24 24">- <title>Microsoft Office</title>- <path d="M21.53 4.306v15.363q0 .807-.472 1.433-.472.627-1.253.85l-6.888 1.974q-.136.037-.29.055-.156.019-.293.019-.396 0-.72-.105-.321-.106-.656-.292l-4.505-2.544q-.248-.137-.391-.366-.143-.23-.143-.515 0-.434.304-.738.304-.305.739-.305h5.831V4.964l-4.38 1.563q-.533.187-.856.658-.322.472-.322 1.03v8.078q0 .496-.248.912-.25.416-.683.651l-2.072 1.13q-.286.148-.571.148-.497 0-.844-.347-.348-.347-.348-.844V6.563q0-.62.33-1.19.328-.571.874-.881L11.07.285q.248-.136.534-.21.285-.075.57-.075.211 0 .38.031.166.031.364.093l6.888 1.899q.384.11.7.329.317.217.547.52.23.305.353.67.125.367.125.764zm-1.588 15.363V4.306q0-.273-.16-.478-.163-.204-.423-.28l-3.388-.93q-.397-.111-.794-.23-.397-.117-.794-.216v19.68l4.976-1.427q.26-.074.422-.28.161-.204.161-.477z" />- </svg>- </a>- </Link>- <Link href={"data:text/calendar," + eventLink()}>- <a- className="mx-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white"- download={props.eventType.title + ".ics"}>- <svg- version="1.1"- fill="currentColor"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 1000 1000"- className="mr-1 -mt-1.5 inline-block h-4 w-4">- <title>{t("other")}</title>- <path d="M971.3,154.9c0-34.7-28.2-62.9-62.9-62.9H611.7c-1.3,0-2.6,0.1-3.9,0.2V10L28.7,87.3v823.4L607.8,990v-84.6c1.3,0.1,2.6,0.2,3.9,0.2h296.7c34.7,0,62.9-28.2,62.9-62.9V154.9z M607.8,636.1h44.6v-50.6h-44.6v-21.9h44.6v-50.6h-44.6v-92h277.9v230.2c0,3.8-3.1,7-7,7H607.8V636.1z M117.9,644.7l-50.6-2.4V397.5l50.6-2.2V644.7z M288.6,607.3c17.6,0.6,37.3-2.8,49.1-7.2l9.1,48c-11,5.1-35.6,9.9-66.9,8.3c-85.4-4.3-127.5-60.7-127.5-132.6c0-86.2,57.8-136.7,133.2-140.1c30.3-1.3,53.7,4,64.3,9.2l-12.2,48.9c-12.1-4.9-28.8-9.2-49.5-8.6c-45.3,1.2-79.5,30.1-79.5,87.4C208.8,572.2,237.8,605.7,288.6,607.3z M455.5,665.2c-32.4-1.6-63.7-11.3-79.1-20.5l12.6-50.7c16.8,9.1,42.9,18.5,70.4,19.4c30.1,1,46.3-10.7,46.3-29.3c0-17.8-14-28.1-48.8-40.6c-46.9-16.4-76.8-41.7-76.8-81.5c0-46.6,39.3-84.1,106.8-87.1c33.3-1.5,58.3,4.2,76.5,11.2l-15.4,53.3c-12.1-5.3-33.5-12.8-62.3-12c-28.3,0.8-41.9,13.6-41.9,28.1c0,17.8,16.1,25.5,53.6,39c52.9,18.5,78.4,45.3,78.4,86.4C575.6,629.7,536.2,669.2,455.5,665.2z M935.3,842.7c0,14.9-12.1,27-27,27H611.7c-1.3,0-2.6-0.2-3.9-0.4V686.2h270.9c19.2,0,34.9-15.6,34.9-34.9V398.4c0-19.2-15.6-34.9-34.9-34.9h-47.1v-32.3H808v32.3h-44.8v-32.3h-22.7v32.3h-43.3v-32.3h-22.7v32.3H628v-32.3h-20.2v-203c1.31.2,2.6-0.4,3.9-0.4h296.7c14.9,0,27,12.1,27,27L935.3,842.7L935.3,842.7z" />- </svg>- </a>- </Link>+ {userIsOwner &&+ !needsConfirmation &&+ !isCancellationMode &&+ !isCancelled &&+ calculatedDuration && (+ <>+ <hr className="border-bookinglightest dark:border-darkgray-300 mt-8" />+ <div className="text-bookingdark align-center flex flex-row justify-center pt-8">+ <span className="flex self-center font-medium text-gray-700 ltr:mr-2 rtl:ml-2 dark:text-gray-50">+ {t("add_to_calendar")}+ </span>+ <div className="justify-left mt-1 flex text-left sm:mt-0">+ <Link+ href={+ `https://calendar.google.com/calendar/r/eventedit?dates=${date+ .utc()+ .format("YYYYMMDDTHHmmss[Z]")}/${date+ .add(calculatedDuration, "minute")+ .utc()+ .format("YYYYMMDDTHHmmss[Z]")}&text=${eventName}&details=${+ props.eventType.description+ }` ++ (typeof location === "string"+ ? "&location=" + encodeURIComponent(location)+ : "") ++ (props.eventType.recurringEvent+ ? "&recur=" ++ encodeURIComponent(new RRule(props.eventType.recurringEvent).toString())+ : "")+ }>+ <a className="mr-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white">+ <svg+ className="-mt-1.5 inline-block h-4 w-4"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24">+ <title>Google</title>+ <path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" />+ </svg>+ </a>+ </Link>+ <Link+ href={+ encodeURI(+ "https://outlook.live.com/calendar/0/deeplink/compose?body=" ++ props.eventType.description ++ "&enddt=" ++ date.add(calculatedDuration, "minute").utc().format() ++ "&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=" ++ date.utc().format() ++ "&subject=" ++ eventName+ ) + (location ? "&location=" + location : "")+ }>+ <a+ className="mx-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white"+ target="_blank">+ <svg+ className="mr-1 -mt-1.5 inline-block h-4 w-4"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24">+ <title>Microsoft Outlook</title>+ <path d="M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V10.85l1.24.72h.01q.1.07.18.18.07.12.07.25zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.8v-2.73zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z" />+ </svg>+ </a>+ </Link>+ <Link+ href={+ encodeURI(+ "https://outlook.office.com/calendar/0/deeplink/compose?body=" ++ props.eventType.description ++ "&enddt=" ++ date.add(calculatedDuration, "minute").utc().format() ++ "&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=" ++ date.utc().format() ++ "&subject=" ++ eventName+ ) + (location ? "&location=" + location : "")+ }>+ <a+ className="mx-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white"+ target="_blank">+ <svg+ className="mr-1 -mt-1.5 inline-block h-4 w-4"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24">+ <title>Microsoft Office</title>+ <path d="M21.53 4.306v15.363q0 .807-.472 1.433-.472.627-1.253.85l-6.888 1.974q-.136.037-.29.055-.156.019-.293.019-.396 0-.72-.105-.321-.106-.656-.292l-4.505-2.544q-.248-.137-.391-.366-.143-.23-.143-.515 0-.434.304-.738.304-.305.739-.305h5.831V4.964l-4.38 1.563q-.533.187-.856.658-.322.472-.322 1.03v8.078q0 .496-.248.912-.25.416-.683.651l-2.072 1.13q-.286.148-.571.148-.497 0-.844-.347-.348-.347-.348-.844V6.563q0-.62.33-1.19.328-.571.874-.881L11.07.285q.248-.136.534-.21.285-.075.57-.075.211 0 .38.031.166.031.364.093l6.888 1.899q.384.11.7.329.317.217.547.52.23.305.353.67.125.367.125.764zm-1.588 15.363V4.306q0-.273-.16-.478-.163-.204-.423-.28l-3.388-.93q-.397-.111-.794-.23-.397-.117-.794-.216v19.68l4.976-1.427q.26-.074.422-.28.161-.204.161-.477z" />+ </svg>+ </a>+ </Link>+ <Link href={"data:text/calendar," + eventLink()}>+ <a+ className="mx-2 h-10 w-10 rounded-sm border border-neutral-200 px-3 py-2 dark:border-neutral-700 dark:text-white"+ download={props.eventType.title + ".ics"}>+ <svg+ version="1.1"+ fill="currentColor"+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 1000 1000"+ className="mr-1 -mt-1.5 inline-block h-4 w-4">+ <title>{t("other")}</title>+ <path d="M971.3,154.9c0-34.7-28.2-62.9-62.9-62.9H611.7c-1.3,0-2.6,0.1-3.9,0.2V10L28.7,87.3v823.4L607.8,990v-84.6c1.3,0.1,2.6,0.2,3.9,0.2h296.7c34.7,0,62.9-28.2,62.9-62.9V154.9z M607.8,636.1h44.6v-50.6h-44.6v-21.9h44.6v-50.6h-44.6v-92h277.9v230.2c0,3.8-3.1,7-7,7H607.8V636.1z M117.9,644.7l-50.6-2.4V397.5l50.6-2.2V644.7z M288.6,607.3c17.6,0.6,37.3-2.8,49.1-7.2l9.1,48c-11,5.1-35.6,9.9-66.9,8.3c-85.4-4.3-127.5-60.7-127.5-132.6c0-86.2,57.8-136.7,133.2-140.1c30.3-1.3,53.7,4,64.3,9.2l-12.2,48.9c-12.1-4.9-28.8-9.2-49.5-8.6c-45.3,1.2-79.5,30.1-79.5,87.4C208.8,572.2,237.8,605.7,288.6,607.3z M455.5,665.2c-32.4-1.6-63.7-11.3-79.1-20.5l12.6-50.7c16.8,9.1,42.9,18.5,70.4,19.4c30.1,1,46.3-10.7,46.3-29.3c0-17.8-14-28.1-48.8-40.6c-46.9-16.4-76.8-41.7-76.8-81.5c0-46.6,39.3-84.1,106.8-87.1c33.3-1.5,58.3,4.2,76.5,11.2l-15.4,53.3c-12.1-5.3-33.5-12.8-62.3-12c-28.3,0.8-41.9,13.6-41.9,28.1c0,17.8,16.1,25.5,53.6,39c52.9,18.5,78.4,45.3,78.4,86.4C575.6,629.7,536.2,669.2,455.5,665.2z M935.3,842.7c0,14.9-12.1,27-27,27H611.7c-1.3,0-2.6-0.2-3.9-0.4V686.2h270.9c19.2,0,34.9-15.6,34.9-34.9V398.4c0-19.2-15.6-34.9-34.9-34.9h-47.1v-32.3H808v32.3h-44.8v-32.3h-22.7v32.3h-43.3v-32.3h-22.7v32.3H628v-32.3h-20.2v-203c1.31.2,2.6-0.4,3.9-0.4h296.7c14.9,0,27,12.1,27,27L935.3,842.7L935.3,842.7z" />+ </svg>+ </a>+ </Link>+ </div></div>- </div>- </>- )}+ </>+ )}{session === null && !(userIsOwner || props.hideBranding) && (<><hr className="border-bookinglightest dark:border-darkgray-300 mt-8" />@@ -669,6 +683,7 @@ type RecurringBookingsProps = {eventType: SuccessProps["eventType"];recurringBookings: SuccessProps["recurringBookings"];date: dayjs.Dayjs;+ duration: number | undefined;is24h: boolean;allRemainingBookings: boolean;isCancelled: boolean;@@ -677,6 +692,7 @@ type RecurringBookingsProps = {export function RecurringBookings({eventType,recurringBookings,+ duration,date,allRemainingBookings,is24h,@@ -689,6 +705,8 @@ export function RecurringBookings({? recurringBookings.sort((a: ConfigType, b: ConfigType) => (dayjs(a).isAfter(dayjs(b)) ? 1 : -1)): null;+ if (!duration) return null;+if (recurringBookingsSorted && allRemainingBookings) {return (<>@@ -707,7 +725,7 @@ export function RecurringBookings({{dayjs.tz(dateStr, timeZone()).format("MMMM DD, YYYY")}<br />{formatTime(dateStr, is24h ? 24 : 12, timeZone())} -{" "}- {formatTime(dayjs(dateStr).add(eventType.length, "m"), is24h ? 24 : 12, timeZone())}{" "}+ {formatTime(dayjs(dateStr).add(duration, "m"), is24h ? 24 : 12, timeZone())}{" "}<span className="text-bookinglight">({timeZone()})</span></div>))}@@ -725,7 +743,7 @@ export function RecurringBookings({{dayjs.tz(dateStr, timeZone()).format("MMMM DD, YYYY")}<br />{formatTime(dateStr, is24h ? 24 : 12, timeZone())} -{" "}- {formatTime(dayjs(dateStr).add(eventType.length, "m"), is24h ? 24 : 12, timeZone())}{" "}+ {formatTime(dayjs(dateStr).add(duration, "m"), is24h ? 24 : 12, timeZone())}{" "}<span className="text-bookinglight">({timeZone()})</span></div>))}@@ -741,7 +759,7 @@ export function RecurringBookings({{dayjs.tz(date, timeZone()).format("MMMM DD, YYYY")}<br />{formatTime(date, is24h ? 24 : 12, timeZone())} -{" "}- {formatTime(dayjs(date).add(eventType.length, "m"), is24h ? 24 : 12, timeZone())}{" "}+ {formatTime(dayjs(date).add(duration, "m"), is24h ? 24 : 12, timeZone())}{" "}<span className="text-bookinglight">({timeZone()})</span></div>);@@ -865,6 +883,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {smsReminderNumber: true,recurringEventId: true,startTime: true,+ endTime: true,location: true,status: true,cancellationReason: true,@@ -901,6 +920,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {// @NOTE: had to do this because Server side cant return [Object objects]// probably fixable with json.stringify -> json.parsebookingInfo["startTime"] = (bookingInfo?.startTime as Date)?.toISOString() as unknown as Date;+ bookingInfo["endTime"] = (bookingInfo?.endTime as Date)?.toISOString() as unknown as Date;const eventTypeRaw = !bookingInfo.eventTypeId? getDefaultEvent(eventTypeSlug || "")diff --git a/apps/web/pages/team/[slug]/book.tsx b/apps/web/pages/team/[slug]/book.tsxindex 44c9fcfbd45..cdeed9c3268 100644--- a/apps/web/pages/team/[slug]/book.tsx+++ b/apps/web/pages/team/[slug]/book.tsx@@ -4,6 +4,7 @@ import { JSONObject } from "superjson/dist/types";import { LocationObject, privacyFilteredLocations } from "@calcom/app-store/locations";import { parseRecurringEvent } from "@calcom/lib";import prisma from "@calcom/prisma";+import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";import { asStringOrNull, asStringOrThrow } from "@lib/asStringOrNull";import getBooking, { GetBookingType } from "@lib/getBooking";@@ -92,7 +93,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {const eventTypeObject = [eventType].map((e) => {return {...e,- metadata: (eventType.metadata || {}) as JSONObject,+ metadata: EventTypeMetaDataSchema.parse(eventType.metadata || {}),periodStartDate: e.periodStartDate?.toString() ?? null,periodEndDate: e.periodEndDate?.toString() ?? null,users: eventType.users.map((u) => ({diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.jsonindex 3ea6f1fa261..b2ff6557fd0 100644--- a/apps/web/public/static/locales/en/common.json+++ b/apps/web/public/static/locales/en/common.json@@ -558,6 +558,10 @@"collective": "Collective","collective_description": "Schedule meetings when all selected team members are available.","duration": "Duration",+ "available_durations": "Available durations",+ "default_duration": "Default duration",+ "default_duration_no_options": "Please choose available durations first",+ "multiple_duration_mins": "{{count}} $t(minute_timeUnit)","minutes": "Minutes","round_robin": "Round Robin","round_robin_description": "Cycle meetings between multiple team members.",@@ -901,6 +905,7 @@"user_impersonation_heading": "User Impersonation","user_impersonation_description": "Allows our support team to temporarily sign in as you to help us quickly resolve any issues you report to us.","team_impersonation_description": "Allows your team members to temporarily sign in as you.",+ "allow_booker_to_select_duration": "Allow booker to select duration","impersonate_user_tip": "All uses of this feature is audited.","impersonating_user_warning": "Impersonating username \"{{user}}\".","impersonating_stop_instructions": "<0>Click Here to stop</0>.",@@ -1105,6 +1110,9 @@"event_limit_tab_description": "How often you can be booked","event_advanced_tab_description": "Calendar settings & more...","event_advanced_tab_title": "Advanced",+ "event_setup_multiple_duration_error": "Event Setup: Multiple durations requires at least 1 option.",+ "event_setup_multiple_duration_default_error": "Event Setup: Please select a valid default duration.",+ "event_setup_booking_limits_error": "Booking limits must be in accending order. [day,week,month,year]","select_which_cal": "Select which calendar to add bookings to","custom_event_name": "Custom event name","custom_event_name_description": "Create customised event names to display on calendar event",diff --git a/packages/prisma/seed.ts b/packages/prisma/seed.tsindex 12af58bedd7..7f7a46b965a 100644--- a/packages/prisma/seed.ts+++ b/packages/prisma/seed.ts@@ -249,6 +249,14 @@ async function main() {slug: "60min",length: 60,},+ {+ title: "Multiple duration",+ slug: "multiple-duration",+ length: 75,+ metadata: {+ multipleDuration: [30, 75, 90],+ },+ },{title: "paid",slug: "paid",diff --git a/packages/prisma/zod-utils.ts b/packages/prisma/zod-utils.tsindex 716cf3a6938..4841a31f419 100644--- a/packages/prisma/zod-utils.ts+++ b/packages/prisma/zod-utils.ts@@ -29,6 +29,7 @@ export const EventTypeMetaDataSchema = z.object({smartContractAddress: z.string().optional(),blockchainId: z.number().optional(),+ multipleDuration: z.number().array().optional(),giphyThankYouPage: z.string().optional(),apps: z.object(appDataSchemas).partial().optional(),additionalNotesRequired: z.boolean().optional(),diff --git a/packages/trpc/server/routers/viewer/slots.tsx b/packages/trpc/server/routers/viewer/slots.tsxindex 82534ae7fe8..86ddba16ba3 100644--- a/packages/trpc/server/routers/viewer/slots.tsx+++ b/packages/trpc/server/routers/viewer/slots.tsx@@ -34,6 +34,11 @@ const getScheduleSchema = z// or list of users (for dynamic events)usernameList: z.array(z.string()).optional(),debug: z.boolean().optional(),+ // to handle event types with multiple duration options+ duration: z+ .string()+ .optional()+ .transform((val) => val && parseInt(val)),}).refine((data) => !!data.eventTypeId || !!data.usernameList,@@ -277,10 +282,10 @@ export async function getSchedule(input: z.infer<typeof getScheduleSchema>, ctx:// get slots retrieves the available times for a given dayconst timeSlots = getTimeSlots({inviteeDate: currentCheckedTime,- eventLength: eventType.length,+ eventLength: input.duration || eventType.length,workingHours,minimumBookingNotice: eventType.minimumBookingNotice,- frequency: eventType.slotInterval || eventType.length,+ frequency: eventType.slotInterval || input.duration || eventType.length,});const endGetSlots = performance.now();diff --git a/packages/ui/v2/modules/event-types/EventTypeDescription.tsx b/packages/ui/v2/modules/event-types/EventTypeDescription.tsxindex 73111c606df..f235a7555b6 100644--- a/packages/ui/v2/modules/event-types/EventTypeDescription.tsx+++ b/packages/ui/v2/modules/event-types/EventTypeDescription.tsx@@ -41,11 +41,21 @@ export const EventTypeDescription = ({ eventType, className }: EventTypeDescript</p>)}<ul className="mt-2 flex flex-wrap space-x-2 sm:flex-nowrap">- <li>- <Badge variant="gray" size="lg" StartIcon={Icon.FiClock}>- {eventType.length}m- </Badge>- </li>+ {eventType.metadata?.multipleDuration ? (+ eventType.metadata.multipleDuration.map((dur, idx) => (+ <li key={idx}>+ <Badge variant="gray" size="lg" StartIcon={Icon.FiClock}>+ {dur}m+ </Badge>+ </li>+ ))+ ) : (+ <li>+ <Badge variant="gray" size="lg" StartIcon={Icon.FiClock}>+ {eventType.length}m+ </Badge>+ </li>+ )}{eventType.schedulingType ? (<li><Badge variant="gray" size="lg" StartIcon={Icon.FiUser}>