refactor: v2 event-types (#15457)
* refactor: UserAvatarGroupWithOrg.tsx remove unecessary profile prop * chore: define event-type types in platform/types * feat: event-type transformes in lib and re-exported through platform-libraries * chore: define user types in platform/types * chore: add users endpoint to platform-constants * refactor: app-store use narrowed down booker event type * chore: version old event-types module * fix: old event-types e2e test * fix: libraries add missing export * fix: reset libraries version to 0 * feat: new event-types module and users endpoints * feat: make booker atom work with v2 event-types * updating event type * refactor: remove guard for get event-types * refactor: move private hook to public * Revert "refactor: remove guard for get event-types" This reverts commit d41204069f1d5bb1305b388ce53399f9175f4249. * Revert "refactor: move private hook to public" This reverts commit 09322e8fba102e57104959f79ed6bfa9a677dc9d. * refactor: get by username and slug in /event-types * remove console log * feat: locations handle displayEventPublicly * test e2e event-types * revert: user output from types * refactor: event-types hooks have private and public folders * refactor: require event-type.slug in input * refactor: demand that all labels of booking fields are unique * refactor: remove unused import * refactor: only have email and name by default in booker * refactor: add booking field slug * fix: display event-type location publicly / hide it in booker * fix: display event-type location publicly / hide it in booker * fix: packages/lib tests * fix: typescript in e2e test * fix: dynamic event types input * refactor: use IsIn instead of IsEnum * refactor: simplify getEventTypes * fix: use ApiAuthGuard instead of AccessTokenGuard * chore: export more stuff from libraries * refactor: SchedulingTypeEnum and Type --------- Co-authored-by: Morgan <[email protected]>
This commit is contained in:
1 parent
c7a96e1b43
commit
0072aba55d
122 files changed
+4738
-523
No files matched your search
@@ -1,13 +1,13 @@
|
||||
import type { z } from "zod";
|
||||
|
||||
import type { EventTypeModel } from "@calcom/prisma/zod";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
export type EventTypeApps = NonNullable<NonNullable<z.infer<typeof EventTypeMetaDataSchema>>["apps"]>;
|
||||
export type EventTypeAppsList = keyof EventTypeApps;
|
||||
|
||||
export const getEventTypeAppData = <T extends EventTypeAppsList>(
|
||||
eventType: Pick<z.infer<typeof EventTypeModel>, "price" | "currency" | "metadata">,
|
||||
eventType: Pick<BookerEvent, "price" | "currency" | "metadata">,
|
||||
appId: T,
|
||||
forcedGet?: boolean
|
||||
): EventTypeApps[T] => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useRef } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { AvailableTimes, AvailableTimesSkeleton } from "@calcom/features/bookings";
|
||||
import type { useEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useNonEmptyScheduleDays } from "@calcom/features/schedules";
|
||||
import { useSlotsForAvailableDates } from "@calcom/features/schedules/lib/use-schedule/useSlotsForDate";
|
||||
import { classNames } from "@calcom/lib";
|
||||
@@ -19,7 +19,9 @@ type AvailableTimeSlotsProps = {
|
||||
isLoading: boolean;
|
||||
seatsPerTimeSlot?: number | null;
|
||||
showAvailableSeatsCount?: boolean | null;
|
||||
event: useEventReturnType;
|
||||
event: {
|
||||
data?: Pick<BookerEvent, "length"> | null;
|
||||
};
|
||||
customClassNames?: {
|
||||
availableTimeSlotsContainer?: string;
|
||||
availableTimeSlotsTitle?: string;
|
||||
|
||||
@@ -4,13 +4,13 @@ import Link from "next/link";
|
||||
import { useMemo, useState } from "react";
|
||||
import type { FieldError } from "react-hook-form";
|
||||
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { IS_CALCOM, WEBSITE_URL } from "@calcom/lib/constants";
|
||||
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Alert, Button, EmptyScreen, Form } from "@calcom/ui";
|
||||
|
||||
import { useBookerStore } from "../../store";
|
||||
import type { useEventReturnType } from "../../utils/event";
|
||||
import type { UseBookingFormReturnType } from "../hooks/useBookingForm";
|
||||
import type { IUseBookingErrors, IUseBookingLoadingStates } from "../hooks/useBookings";
|
||||
import { BookingFields } from "./BookingFields";
|
||||
@@ -43,7 +43,11 @@ export const BookEventForm = ({
|
||||
extraOptions,
|
||||
isPlatform = false,
|
||||
}: Omit<BookEventFormProps, "event"> & {
|
||||
eventQuery: useEventReturnType;
|
||||
eventQuery: {
|
||||
isError: boolean;
|
||||
isPending: boolean;
|
||||
data?: Pick<BookerEvent, "price" | "currency" | "metadata" | "bookingFields" | "locations"> | null;
|
||||
};
|
||||
rescheduleUid: string | null;
|
||||
}) => {
|
||||
const eventType = eventQuery.data;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ReactNode } from "react";
|
||||
import React from "react";
|
||||
|
||||
import { useIsPlatform, useGetEventTypeById } from "@calcom/atoms/monorepo";
|
||||
import { useEventTypeById, useIsPlatform } from "@calcom/atoms/monorepo";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Badge, Dialog, DialogContent } from "@calcom/ui";
|
||||
|
||||
@@ -25,14 +25,10 @@ const PlatformBookEventFormWrapper = ({
|
||||
children: ReactNode;
|
||||
}) => {
|
||||
const eventId = useBookerStore((state) => state.eventId);
|
||||
const { data } = useGetEventTypeById(eventId);
|
||||
const { data } = useEventTypeById(eventId);
|
||||
|
||||
return (
|
||||
<BookEventFormWrapperComponent
|
||||
child={children}
|
||||
eventLength={data?.eventType.length}
|
||||
onCancel={onCancel}
|
||||
/>
|
||||
<BookEventFormWrapperComponent child={children} eventLength={data?.lengthInMinutes} onCancel={onCancel} />
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ import { default as DatePickerComponent } from "@calcom/features/calendars/DateP
|
||||
import { useNonEmptyScheduleDays } from "@calcom/features/schedules";
|
||||
import { weekdayToWeekIndex } from "@calcom/lib/date-fns";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
|
||||
import { useBookerStore } from "../store";
|
||||
import type { useEventReturnType, useScheduleForEventReturnType } from "../utils/event";
|
||||
import type { useScheduleForEventReturnType } from "../utils/event";
|
||||
|
||||
export const DatePicker = ({
|
||||
event,
|
||||
@@ -16,7 +17,9 @@ export const DatePicker = ({
|
||||
classNames,
|
||||
scrollToTimeSlots,
|
||||
}: {
|
||||
event: useEventReturnType;
|
||||
event: {
|
||||
data?: { users: Pick<User, "weekStart">[] } | null;
|
||||
};
|
||||
schedule: useScheduleForEventReturnType;
|
||||
classNames?: {
|
||||
datePickerContainer?: string;
|
||||
|
||||
@@ -9,12 +9,12 @@ import { EventDetails, EventMembers, EventMetaSkeleton, EventTitle } from "@calc
|
||||
import { SeatsAvailabilityText } from "@calcom/features/bookings/components/SeatsAvailabilityText";
|
||||
import { EventMetaBlock } from "@calcom/features/bookings/components/event-meta/Details";
|
||||
import { useTimePreferences } from "@calcom/features/bookings/lib";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import { fadeInUp } from "../config";
|
||||
import { useBookerStore } from "../store";
|
||||
import { FromToTime } from "../utils/dates";
|
||||
import type { useEventReturnType } from "../utils/event";
|
||||
|
||||
const WebTimezoneSelect = dynamic(
|
||||
() => import("@calcom/ui/components/form/timezone-select/TimezoneSelect").then((mod) => mod.TimezoneSelect),
|
||||
@@ -29,8 +29,27 @@ export const EventMeta = ({
|
||||
isPlatform = true,
|
||||
classNames,
|
||||
}: {
|
||||
event: useEventReturnType["data"];
|
||||
isPending: useEventReturnType["isPending"];
|
||||
event?: Pick<
|
||||
BookerEvent,
|
||||
| "lockTimeZoneToggleOnBookingPage"
|
||||
| "schedule"
|
||||
| "seatsPerTimeSlot"
|
||||
| "users"
|
||||
| "length"
|
||||
| "schedulingType"
|
||||
| "profile"
|
||||
| "entity"
|
||||
| "description"
|
||||
| "title"
|
||||
| "metadata"
|
||||
| "locations"
|
||||
| "currency"
|
||||
| "requiresConfirmation"
|
||||
| "recurringEvent"
|
||||
| "price"
|
||||
| "isDynamic"
|
||||
> | null;
|
||||
isPending: boolean;
|
||||
isPlatform?: boolean;
|
||||
classNames?: {
|
||||
eventMetaContainer?: string;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import type { useEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
import { SchedulingType } from "@calcom/prisma/enums";
|
||||
import { Button, UserAvatarGroupWithOrg } from "@calcom/ui";
|
||||
|
||||
interface IInstantBookingProps {
|
||||
onConnectNow: () => void;
|
||||
event: NonNullable<useEventReturnType["data"]>;
|
||||
event: Pick<BookerEvent, "entity" | "schedulingType"> & {
|
||||
users: (Pick<User, "name" | "username" | "avatarUrl"> & { bookerUrl: string })[];
|
||||
};
|
||||
}
|
||||
|
||||
export const InstantBooking = ({ onConnectNow, event }: IInstantBookingProps) => {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { useMemo, useEffect } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { Calendar } from "@calcom/features/calendars/weeklyview";
|
||||
import type { CalendarEvent } from "@calcom/features/calendars/weeklyview/types/events";
|
||||
import type { CalendarAvailableTimeslots } from "@calcom/features/calendars/weeklyview/types/state";
|
||||
import { localStorage } from "@calcom/lib/webstorage";
|
||||
|
||||
import { useBookerStore } from "../store";
|
||||
import type { useEventReturnType, useScheduleForEventReturnType } from "../utils/event";
|
||||
import type { useScheduleForEventReturnType } from "../utils/event";
|
||||
import { getQueryParam } from "../utils/query-param";
|
||||
import { useOverlayCalendarStore } from "./OverlayCalendar/store";
|
||||
|
||||
@@ -20,7 +21,9 @@ export const LargeCalendar = ({
|
||||
extraDays: number;
|
||||
schedule?: useScheduleForEventReturnType["data"];
|
||||
isLoading: boolean;
|
||||
event: useEventReturnType;
|
||||
event: {
|
||||
data?: Pick<BookerEvent, "length"> | null;
|
||||
};
|
||||
}) => {
|
||||
const selectedDate = useBookerStore((state) => state.selectedDate);
|
||||
const setSelectedTimeslot = useBookerStore((state) => state.setSelectedTimeslot);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useRef } from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import { useEmbedType, useEmbedUiConfig, useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
|
||||
import type { BookerLayouts } from "@calcom/prisma/zod-utils";
|
||||
import { defaultBookerLayoutSettings } from "@calcom/prisma/zod-utils";
|
||||
@@ -9,13 +10,12 @@ import { defaultBookerLayoutSettings } from "@calcom/prisma/zod-utils";
|
||||
import { extraDaysConfig } from "../../config";
|
||||
import { useBookerStore } from "../../store";
|
||||
import type { BookerLayout } from "../../types";
|
||||
import type { useEventReturnType } from "../../utils/event";
|
||||
import { validateLayout } from "../../utils/layout";
|
||||
import { getQueryParam } from "../../utils/query-param";
|
||||
|
||||
export type UseBookerLayoutType = ReturnType<typeof useBookerLayout>;
|
||||
|
||||
export const useBookerLayout = (event: useEventReturnType["data"]) => {
|
||||
export const useBookerLayout = (event: Pick<BookerEvent, "profile"> | undefined | null) => {
|
||||
const [_layout, setLayout] = useBookerStore((state) => [state.layout, state.setLayout], shallow);
|
||||
const isEmbed = useIsEmbed();
|
||||
const isMobile = useMediaQuery("(max-width: 768px)");
|
||||
|
||||
@@ -5,14 +5,14 @@ import { z } from "zod";
|
||||
|
||||
import type { EventLocationType } from "@calcom/app-store/locations";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { useEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import getBookingResponsesSchema from "@calcom/features/bookings/lib/getBookingResponsesSchema";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import { useInitialFormValues } from "./useInitialFormValues";
|
||||
|
||||
export interface IUseBookingForm {
|
||||
event: useEventReturnType["data"];
|
||||
event?: Pick<BookerEvent, "bookingFields"> | null;
|
||||
sessionEmail?: string | null;
|
||||
sessionName?: string | null;
|
||||
sessionUsername?: string | null;
|
||||
|
||||
@@ -7,9 +7,9 @@ import { useHandleBookEvent } from "@calcom/atoms/monorepo";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { sdkActionManager } from "@calcom/embed-core/embed-iframe";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { useEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import { updateQueryParam, getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
|
||||
import { createBooking, createRecurringBooking, createInstantBooking } from "@calcom/features/bookings/lib";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { getFullName } from "@calcom/features/form-builder/utils";
|
||||
import { useBookingSuccessRedirect } from "@calcom/lib/bookingSuccessRedirect";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -21,7 +21,29 @@ import { showToast } from "@calcom/ui";
|
||||
import type { UseBookingFormReturnType } from "./useBookingForm";
|
||||
|
||||
export interface IUseBookings {
|
||||
event: useEventReturnType;
|
||||
event: {
|
||||
data?:
|
||||
| (Pick<
|
||||
BookerEvent,
|
||||
| "id"
|
||||
| "slug"
|
||||
| "hosts"
|
||||
| "requiresConfirmation"
|
||||
| "isDynamic"
|
||||
| "metadata"
|
||||
| "forwardParamsSuccessRedirect"
|
||||
| "successRedirectUrl"
|
||||
| "length"
|
||||
| "recurringEvent"
|
||||
| "schedulingType"
|
||||
> & {
|
||||
users: Pick<
|
||||
BookerEvent["users"][number],
|
||||
"name" | "username" | "avatarUrl" | "weekStart" | "profile" | "bookerUrl"
|
||||
>[];
|
||||
})
|
||||
| null;
|
||||
};
|
||||
hashedLink?: string | null;
|
||||
bookingForm: UseBookingFormReturnType["bookingForm"];
|
||||
metadata: Record<string, string>;
|
||||
|
||||
@@ -2,14 +2,14 @@ import { useEffect, useState } from "react";
|
||||
import type { z } from "zod";
|
||||
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { useEvent } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type getBookingResponsesSchema from "@calcom/features/bookings/lib/getBookingResponsesSchema";
|
||||
import { getBookingResponsesPartialSchema } from "@calcom/features/bookings/lib/getBookingResponsesSchema";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
|
||||
export type useInitialFormValuesReturnType = ReturnType<typeof useInitialFormValues>;
|
||||
|
||||
type UseInitialFormValuesProps = {
|
||||
eventType: ReturnType<typeof useEvent>["data"];
|
||||
eventType?: Pick<BookerEvent, "bookingFields"> | null;
|
||||
rescheduleUid: string | null;
|
||||
isRescheduling: boolean;
|
||||
email?: string | null;
|
||||
|
||||
@@ -4,13 +4,13 @@ import { shallow } from "zustand/shallow";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { useSlotReservationId } from "@calcom/features/bookings/Booker/useSlotReservationId";
|
||||
import type { useEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { MINUTES_TO_BOOK } from "@calcom/lib/constants";
|
||||
import { trpc } from "@calcom/trpc";
|
||||
|
||||
export type UseSlotsReturnType = ReturnType<typeof useSlots>;
|
||||
|
||||
export const useSlots = (event: useEventReturnType) => {
|
||||
export const useSlots = (event: { data?: Pick<BookerEvent, "id" | "length"> | null }) => {
|
||||
const selectedDuration = useBookerStore((state) => state.selectedDuration);
|
||||
const [selectedTimeslot, setSelectedTimeslot] = useBookerStore(
|
||||
(state) => [state.selectedTimeslot, state.setSelectedTimeslot],
|
||||
|
||||
@@ -5,10 +5,8 @@ import type { UseCalendarsReturnType } from "@calcom/features/bookings/Booker/co
|
||||
import type { UseSlotsReturnType } from "@calcom/features/bookings/Booker/components/hooks/useSlots";
|
||||
import type { UseVerifyCodeReturnType } from "@calcom/features/bookings/Booker/components/hooks/useVerifyCode";
|
||||
import type { UseVerifyEmailReturnType } from "@calcom/features/bookings/Booker/components/hooks/useVerifyEmail";
|
||||
import type {
|
||||
useEventReturnType,
|
||||
useScheduleForEventReturnType,
|
||||
} from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type { useScheduleForEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type { BookerEventQuery } from "@calcom/features/bookings/types";
|
||||
import type { BookerLayouts } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import type { GetBookingType } from "../lib/get-booking";
|
||||
@@ -106,7 +104,7 @@ export type WrappedBookerPropsMain = {
|
||||
slots: UseSlotsReturnType;
|
||||
calendars: UseCalendarsReturnType;
|
||||
bookerForm: UseBookingFormReturnType;
|
||||
event: useEventReturnType;
|
||||
event: BookerEventQuery;
|
||||
schedule: useScheduleForEventReturnType;
|
||||
bookerLayout: UseBookerLayoutType;
|
||||
verifyEmail: UseVerifyEmailReturnType;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useIsPlatform } from "@calcom/atoms/monorepo";
|
||||
import type { IOutOfOfficeData } from "@calcom/core/getUserAvailability";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { OutOfOfficeInSlots } from "@calcom/features/bookings/Booker/components/OutOfOfficeInSlots";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import type { Slots } from "@calcom/features/schedules";
|
||||
import { classNames } from "@calcom/lib";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -15,7 +16,6 @@ import type { IGetAvailableSlots } from "@calcom/trpc/server/routers/viewer/slot
|
||||
import { Button, Icon, SkeletonText } from "@calcom/ui";
|
||||
|
||||
import { useBookerStore } from "../Booker/store";
|
||||
import type { useEventReturnType } from "../Booker/utils/event";
|
||||
import { getQueryParam } from "../Booker/utils/query-param";
|
||||
import { useTimePreferences } from "../lib";
|
||||
import { useCheckOverlapWithOverlay } from "../lib/useCheckOverlapWithOverlay";
|
||||
@@ -36,7 +36,9 @@ type AvailableTimesProps = {
|
||||
showTimeFormatToggle?: boolean;
|
||||
className?: string;
|
||||
selectedSlots?: string[];
|
||||
event: useEventReturnType;
|
||||
event: {
|
||||
data?: Pick<BookerEvent, "length"> | null;
|
||||
};
|
||||
customClassNames?: string;
|
||||
};
|
||||
|
||||
@@ -54,7 +56,9 @@ const SlotItem = ({
|
||||
selectedSlots?: string[];
|
||||
onTimeSelect: TOnTimeSelect;
|
||||
showAvailableSeatsCount?: boolean | null;
|
||||
event: useEventReturnType;
|
||||
event: {
|
||||
data?: Pick<BookerEvent, "length"> | null;
|
||||
};
|
||||
customClassNames?: string;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
|
||||
@@ -2,12 +2,12 @@ import React, { Fragment } from "react";
|
||||
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { PriceIcon } from "@calcom/features/bookings/components/event-meta/PriceIcon";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Icon, type IconName } from "@calcom/ui";
|
||||
|
||||
import type { PublicEvent } from "../../types";
|
||||
import { EventDetailBlocks } from "../../types";
|
||||
import { AvailableEventLocations } from "./AvailableEventLocations";
|
||||
import { EventDuration } from "./Duration";
|
||||
@@ -15,7 +15,17 @@ import { EventOccurences } from "./Occurences";
|
||||
import { Price } from "./Price";
|
||||
|
||||
type EventDetailsPropsBase = {
|
||||
event: PublicEvent;
|
||||
event: Pick<
|
||||
BookerEvent,
|
||||
| "currency"
|
||||
| "price"
|
||||
| "locations"
|
||||
| "requiresConfirmation"
|
||||
| "recurringEvent"
|
||||
| "length"
|
||||
| "metadata"
|
||||
| "isDynamic"
|
||||
>;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@ import { useEffect } from "react";
|
||||
|
||||
import { useIsPlatform } from "@calcom/atoms/monorepo";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Badge } from "@calcom/ui";
|
||||
|
||||
import type { PublicEvent } from "../../types";
|
||||
|
||||
/** Render X mins as X hours or X hours Y mins instead of in minutes once >= 60 minutes */
|
||||
export const getDurationFormatted = (mins: number | undefined, t: TFunction) => {
|
||||
if (!mins) return null;
|
||||
@@ -36,7 +35,11 @@ export const getDurationFormatted = (mins: number | undefined, t: TFunction) =>
|
||||
return hourStr || minStr;
|
||||
};
|
||||
|
||||
export const EventDuration = ({ event }: { event: PublicEvent }) => {
|
||||
export const EventDuration = ({
|
||||
event,
|
||||
}: {
|
||||
event: Pick<BookerEvent, "length" | "metadata" | "isDynamic">;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const isPlatform = useIsPlatform();
|
||||
const [selectedDuration, setSelectedDuration, state] = useBookerStore((state) => [
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import type { PublicEvent } from "bookings/types";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import { Examples, Example, VariantsTable, VariantRow } from "@calcom/storybook/components";
|
||||
@@ -49,9 +48,15 @@ export const AllVariants: Story = {
|
||||
<EventMembers
|
||||
users={mockEvent.users}
|
||||
schedulingType="COLLECTIVE"
|
||||
entity={{ isUnpublished: false, name: "Example", orgSlug: null }}
|
||||
entity={{
|
||||
considerUnpublished: false,
|
||||
fromRedirectOfNonOrgLink: true,
|
||||
teamSlug: null,
|
||||
name: "Example",
|
||||
orgSlug: null,
|
||||
}}
|
||||
// TODO remove type assertion
|
||||
profile={{ weekStart: "Sunday" } as PublicEvent["profile"]}
|
||||
profile={{ bookerLayouts: null }}
|
||||
/>
|
||||
<EventTitle>Quick catch-up</EventTitle>
|
||||
<EventDetails event={mockEvent} />
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { getEventLocationType, getTranslatedLocation } from "@calcom/app-store/locations";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { classNames } from "@calcom/lib";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Tooltip } from "@calcom/ui";
|
||||
|
||||
import type { PublicEvent } from "../../types";
|
||||
import { EventMetaBlock } from "./Details";
|
||||
|
||||
export const EventLocations = ({ event }: { event: PublicEvent }) => {
|
||||
export const EventLocations = ({ event }: { event: BookerEvent }) => {
|
||||
const { t } = useLocale();
|
||||
const locations = event.locations;
|
||||
|
||||
if (!locations?.length) return null;
|
||||
|
||||
const getLocationToDisplay = (location: PublicEvent["locations"][number]) => {
|
||||
const getLocationToDisplay = (location: BookerEvent["locations"][number]) => {
|
||||
const eventLocationType = getEventLocationType(location.type);
|
||||
const translatedLocation = getTranslatedLocation(location, eventLocationType, t);
|
||||
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
|
||||
import { getTeamUrlSync } from "@calcom/lib/getBookerUrl/client";
|
||||
import { SchedulingType } from "@calcom/prisma/enums";
|
||||
import { AvatarGroup } from "@calcom/ui";
|
||||
|
||||
import type { PublicEvent } from "../../types";
|
||||
|
||||
export interface EventMembersProps {
|
||||
/**
|
||||
* Used to determine whether all members should be shown or not.
|
||||
* In case of Round Robin type, members aren't shown.
|
||||
*/
|
||||
schedulingType: PublicEvent["schedulingType"];
|
||||
users: PublicEvent["users"];
|
||||
profile: PublicEvent["profile"];
|
||||
entity: PublicEvent["entity"];
|
||||
schedulingType: BookerEvent["schedulingType"];
|
||||
users: BookerEvent["users"];
|
||||
profile: BookerEvent["profile"];
|
||||
entity: BookerEvent["entity"];
|
||||
}
|
||||
|
||||
export const EventMembers = ({ schedulingType, users, profile, entity }: EventMembersProps) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { parseRecurringDates } from "@calcom/lib/parse-dates";
|
||||
import { getRecurringFreq } from "@calcom/lib/recurringStrings";
|
||||
@@ -8,9 +9,8 @@ import { Tooltip, Alert } from "@calcom/ui";
|
||||
import { Input } from "@calcom/ui";
|
||||
|
||||
import { useTimePreferences } from "../../lib";
|
||||
import type { PublicEvent } from "../../types";
|
||||
|
||||
export const EventOccurences = ({ event }: { event: PublicEvent }) => {
|
||||
export const EventOccurences = ({ event }: { event: Pick<BookerEvent, "recurringEvent"> }) => {
|
||||
const maxOccurences = event.recurringEvent?.count || null;
|
||||
const { t, i18n } = useLocale();
|
||||
const [setRecurringEventCount, recurringEventCount, setOccurenceCount, occurenceCount] = useBookerStore(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PublicEvent } from "bookings/types";
|
||||
import type { BookerEvent } from "bookings/types";
|
||||
|
||||
export const mockEvent: PublicEvent = {
|
||||
export const mockEvent: BookerEvent = {
|
||||
id: 1,
|
||||
title: "Quick check-in",
|
||||
slug: "quick-check-in",
|
||||
@@ -8,10 +8,10 @@ export const mockEvent: PublicEvent = {
|
||||
description:
|
||||
"Use this event for a quick 15 minute catchup. Visit this long url to test the component https://cal.com/averylongurlwithoutspacesthatshouldntbreaklayout",
|
||||
users: [
|
||||
{ name: "Pro example", username: "pro", weekStart: "Sunday", organizationId: null },
|
||||
{ name: "Team example", username: "team", weekStart: "Sunday", organizationId: 1 },
|
||||
{ name: "Pro example", username: "pro", weekStart: "Sunday", avatarUrl: "", profile: null },
|
||||
{ name: "Team example", username: "team", weekStart: "Sunday", avatarUrl: "", profile: null },
|
||||
],
|
||||
schedulingType: null,
|
||||
length: 30,
|
||||
locations: [{ type: "integrations:google:meet" }, { type: "integrations:zoom" }],
|
||||
} as PublicEvent; // TODO: complete mock and remove type assertion
|
||||
};
|
||||
@@ -3,11 +3,11 @@ import { v4 as uuidv4 } from "uuid";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { parseRecurringDates } from "@calcom/lib/parse-dates";
|
||||
|
||||
import type { PublicEvent, BookingCreateBody, RecurringBookingCreateBody } from "../../types";
|
||||
import type { BookerEvent, BookingCreateBody, RecurringBookingCreateBody } from "../../types";
|
||||
|
||||
export type BookingOptions = {
|
||||
values: Record<string, unknown>;
|
||||
event: PublicEvent;
|
||||
event: Pick<BookerEvent, "id" | "length" | "slug" | "schedulingType" | "recurringEvent">;
|
||||
date: string;
|
||||
// @NOTE: duration is not validated in this function
|
||||
duration: number | undefined | null;
|
||||
|
||||
@@ -6,6 +6,53 @@ import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import type { AppsStatus } from "@calcom/types/Calendar";
|
||||
|
||||
export type PublicEvent = NonNullable<RouterOutputs["viewer"]["public"]["event"]>;
|
||||
|
||||
export type BookerEventQuery = {
|
||||
isSuccess: boolean;
|
||||
isError: boolean;
|
||||
isPending: boolean;
|
||||
data?: BookerEvent | null;
|
||||
};
|
||||
|
||||
type BookerEventUser = Pick<
|
||||
PublicEvent["users"][number],
|
||||
"name" | "username" | "avatarUrl" | "weekStart" | "profile"
|
||||
> & {
|
||||
metadata?: undefined;
|
||||
brandColor?: string | null;
|
||||
darkBrandColor?: string | null;
|
||||
bookerUrl: string;
|
||||
};
|
||||
|
||||
type BookerEventProfile = Pick<PublicEvent["profile"], "name" | "image" | "bookerLayouts">;
|
||||
|
||||
export type BookerEvent = Pick<
|
||||
PublicEvent,
|
||||
| "id"
|
||||
| "length"
|
||||
| "slug"
|
||||
| "schedulingType"
|
||||
| "recurringEvent"
|
||||
| "entity"
|
||||
| "locations"
|
||||
| "metadata"
|
||||
| "isDynamic"
|
||||
| "requiresConfirmation"
|
||||
| "price"
|
||||
| "currency"
|
||||
| "lockTimeZoneToggleOnBookingPage"
|
||||
| "schedule"
|
||||
| "seatsPerTimeSlot"
|
||||
| "title"
|
||||
| "description"
|
||||
| "forwardParamsSuccessRedirect"
|
||||
| "successRedirectUrl"
|
||||
| "hosts"
|
||||
| "bookingFields"
|
||||
| "seatsShowAvailabilityCount"
|
||||
| "isInstantEvent"
|
||||
> & { users: BookerEventUser[] } & { profile: BookerEventProfile };
|
||||
|
||||
export type ValidationErrors<T extends object> = { key: FieldPath<T>; error: ErrorOption }[];
|
||||
|
||||
export type EventPrice = { currency: string; price: number; displayAlternateSymbol?: boolean };
|
||||
|
||||
@@ -108,7 +108,7 @@ const commons = {
|
||||
secondaryEmail: null,
|
||||
};
|
||||
|
||||
const dynamicEvent = {
|
||||
export const dynamicEvent = {
|
||||
length: 30,
|
||||
slug: "dynamic",
|
||||
title: "Group Meeting",
|
||||
@@ -120,7 +120,7 @@ const dynamicEvent = {
|
||||
metadata: EventTypeMetaDataSchema.parse({ multipleDuration: [15, 30, 45, 60, 90] }),
|
||||
};
|
||||
|
||||
const defaultEvents = [dynamicEvent];
|
||||
export const defaultEvents = [dynamicEvent];
|
||||
|
||||
export const getDynamicEventDescription = (dynamicUsernames: string[], slug: string): string => {
|
||||
return `Book a ${slug} min event with ${dynamicUsernames.join(", ")}`;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./transformers";
|
||||
@@ -0,0 +1,540 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { BookingField_2024_06_14, Location_2024_06_14 } from "@calcom/platform-types";
|
||||
|
||||
import type { CommonField, OptionsField } from "./api-request";
|
||||
import {
|
||||
transformApiEventTypeLocations,
|
||||
transformApiEventTypeBookingFields,
|
||||
transformSelectOptions,
|
||||
} from "./api-request";
|
||||
|
||||
describe("transformApiEventTypeLocations", () => {
|
||||
it("should transform address", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
{
|
||||
type: "address",
|
||||
address: "London road 10-1",
|
||||
public: true,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [{ type: "inPerson", address: "London road 10-1", displayLocationPublicly: true }];
|
||||
|
||||
const result = transformApiEventTypeLocations(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform link", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
{
|
||||
type: "link",
|
||||
link: "https://customvideo.com/join/123456",
|
||||
public: true,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{ type: "link", link: "https://customvideo.com/join/123456", displayLocationPublicly: true },
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeLocations(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform integration", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
{
|
||||
type: "integration",
|
||||
integration: "cal-video",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [{ type: "integrations:daily" }];
|
||||
|
||||
const result = transformApiEventTypeLocations(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform phone", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
{
|
||||
type: "phone",
|
||||
phone: "+37120993151",
|
||||
public: true,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{ type: "userPhone", hostPhoneNumber: "+37120993151", displayLocationPublicly: true },
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeLocations(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
|
||||
describe("transformApiEventTypeBookingFields", () => {
|
||||
it("should transform name field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "name",
|
||||
slug: "name",
|
||||
label: "Your name",
|
||||
required: true,
|
||||
placeholder: "alice",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform email field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "email",
|
||||
slug: "email",
|
||||
label: "Your email",
|
||||
required: true,
|
||||
placeholder: "[email protected]",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform phone field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "phone",
|
||||
slug: "phone",
|
||||
label: "Your phone number",
|
||||
required: true,
|
||||
placeholder: "123456789",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform address field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "address",
|
||||
slug: "address",
|
||||
label: "Your address",
|
||||
required: true,
|
||||
placeholder: "1234 Main St",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform text field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "text",
|
||||
slug: "text",
|
||||
label: "Your text",
|
||||
required: true,
|
||||
placeholder: "Enter your text",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform number field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "number",
|
||||
slug: "number",
|
||||
label: "Your number",
|
||||
required: true,
|
||||
placeholder: "100",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform textarea field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "textarea",
|
||||
slug: "textarea",
|
||||
label: "Your detailed information",
|
||||
required: true,
|
||||
placeholder: "Detailed description here...",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform select field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "select",
|
||||
slug: "select",
|
||||
label: "Your selection",
|
||||
required: true,
|
||||
placeholder: "Select...",
|
||||
options: ["Option 1", "Option 2"],
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: OptionsField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
options: transformSelectOptions(bookingField.options),
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform multiselect field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "multiselect",
|
||||
slug: "multiselect",
|
||||
label: "Your multiple selections",
|
||||
required: true,
|
||||
options: ["Option 1", "Option 2"],
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: OptionsField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: "",
|
||||
options: transformSelectOptions(bookingField.options),
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform multiemail field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "multiemail",
|
||||
slug: "multiemail",
|
||||
label: "Your multiple emails",
|
||||
required: true,
|
||||
placeholder: "[email protected]",
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: bookingField.placeholder,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform checkbox field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "checkbox",
|
||||
slug: "checkbox",
|
||||
label: "Your checkboxes",
|
||||
required: true,
|
||||
options: ["Checkbox 1", "Checkbox 2"],
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: OptionsField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: "",
|
||||
options: transformSelectOptions(bookingField.options),
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform radio field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "radio",
|
||||
slug: "radio",
|
||||
label: "Your radio buttons",
|
||||
required: true,
|
||||
options: ["Radio 1", "Radio 2"],
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: OptionsField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: "",
|
||||
options: transformSelectOptions(bookingField.options),
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform boolean field", () => {
|
||||
const bookingField: BookingField_2024_06_14 = {
|
||||
type: "boolean",
|
||||
slug: "boolean",
|
||||
label: "Agree to terms?",
|
||||
required: true,
|
||||
};
|
||||
|
||||
const input: BookingField_2024_06_14[] = [bookingField];
|
||||
|
||||
const expectedOutput: CommonField[] = [
|
||||
{
|
||||
name: bookingField.slug,
|
||||
type: bookingField.type,
|
||||
label: bookingField.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: bookingField.required,
|
||||
placeholder: "",
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformApiEventTypeBookingFields(input);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,204 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import type { CreateEventTypeInput_2024_06_14, Integration_2024_06_14 } from "@calcom/platform-types";
|
||||
|
||||
const integrationsMapping: Record<Integration_2024_06_14, string> = {
|
||||
"cal-video": "integrations:daily",
|
||||
};
|
||||
|
||||
function transformApiEventTypeLocations(inputLocations: CreateEventTypeInput_2024_06_14["locations"]) {
|
||||
if (!inputLocations) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return inputLocations.map((location) => {
|
||||
const { type } = location;
|
||||
switch (type) {
|
||||
case "address":
|
||||
return { type: "inPerson", address: location.address, displayLocationPublicly: location.public };
|
||||
case "link":
|
||||
return { type: "link", link: location.link, displayLocationPublicly: location.public };
|
||||
case "integration":
|
||||
const integrationLabel = integrationsMapping[location.integration];
|
||||
return { type: integrationLabel };
|
||||
case "phone":
|
||||
return {
|
||||
type: "userPhone",
|
||||
hostPhoneNumber: location.phone,
|
||||
displayLocationPublicly: location.public,
|
||||
};
|
||||
default:
|
||||
throw new Error(`Unsupported location type '${type}'`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const integrationsMappingSchema = {
|
||||
"cal-video": z.literal("integrations:daily"),
|
||||
};
|
||||
|
||||
const InPersonSchema = z.object({
|
||||
type: z.literal("inPerson"),
|
||||
address: z.string(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const LinkSchema = z.object({
|
||||
type: z.literal("link"),
|
||||
link: z.string().url(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const IntegrationSchema = z.object({
|
||||
type: z.union([integrationsMappingSchema["cal-video"], integrationsMappingSchema["cal-video"]]),
|
||||
});
|
||||
|
||||
const UserPhoneSchema = z.object({
|
||||
type: z.literal("userPhone"),
|
||||
hostPhoneNumber: z.string(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const TransformedLocationSchema = z.union([InPersonSchema, LinkSchema, IntegrationSchema, UserPhoneSchema]);
|
||||
export const TransformedLocationsSchema = z.array(TransformedLocationSchema);
|
||||
|
||||
function transformApiEventTypeBookingFields(
|
||||
inputBookingFields: CreateEventTypeInput_2024_06_14["bookingFields"]
|
||||
) {
|
||||
if (!inputBookingFields) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const customBookingFields = inputBookingFields.map((field) => {
|
||||
const commonFields: CommonField = {
|
||||
name: field.slug,
|
||||
type: field.type,
|
||||
label: field.label,
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: field.required,
|
||||
placeholder: "placeholder" in field && field.placeholder ? field.placeholder : "",
|
||||
};
|
||||
|
||||
const options = "options" in field && field.options ? transformSelectOptions(field.options) : undefined;
|
||||
|
||||
if (!options) {
|
||||
return commonFields;
|
||||
}
|
||||
|
||||
return {
|
||||
...commonFields,
|
||||
options,
|
||||
};
|
||||
});
|
||||
|
||||
return customBookingFields;
|
||||
}
|
||||
|
||||
export function transformSelectOptions(options: string[]) {
|
||||
return options.map((option) => ({
|
||||
label: option,
|
||||
value: option,
|
||||
}));
|
||||
}
|
||||
|
||||
const FieldTypeEnum = z.enum([
|
||||
"number",
|
||||
"boolean",
|
||||
"address",
|
||||
"name",
|
||||
"text",
|
||||
"textarea",
|
||||
"email",
|
||||
"phone",
|
||||
"multiemail",
|
||||
"select",
|
||||
"multiselect",
|
||||
"checkbox",
|
||||
"radio",
|
||||
"radioInput",
|
||||
]);
|
||||
|
||||
const CommonFieldsSchema = z.object({
|
||||
name: z.string(),
|
||||
type: FieldTypeEnum,
|
||||
label: z.string(),
|
||||
sources: z.array(
|
||||
z.object({
|
||||
id: z.literal("user"),
|
||||
type: z.literal("user"),
|
||||
label: z.literal("User"),
|
||||
fieldRequired: z.literal(true),
|
||||
})
|
||||
),
|
||||
editable: z.literal("user"),
|
||||
required: z.boolean(),
|
||||
placeholder: z.string().optional(),
|
||||
});
|
||||
|
||||
const SystemFieldsSchema = z.object({
|
||||
name: z.string(),
|
||||
type: FieldTypeEnum,
|
||||
defaultLabel: z.string(),
|
||||
labe: z.string().optional(),
|
||||
editable: z.enum(["system-but-optional", "system"]),
|
||||
sources: z.array(
|
||||
z.object({
|
||||
id: z.literal("default"),
|
||||
type: z.literal("default"),
|
||||
label: z.literal("Default"),
|
||||
})
|
||||
),
|
||||
views: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.enum(["reschedule"]),
|
||||
label: z.string(),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
defaultPlaceholder: z.enum(["", "share_additional_notes", "email", "reschedule_placeholder"]).optional(),
|
||||
hidden: z.boolean().optional(),
|
||||
required: z.boolean(),
|
||||
hideWhenJustOneOption: z.boolean().optional(),
|
||||
getOptionsAt: z.enum(["locations"]).optional(),
|
||||
optionsInputs: z
|
||||
.object({
|
||||
attendeeInPerson: z.object({
|
||||
type: z.literal("address"),
|
||||
required: z.boolean(),
|
||||
placeholder: z.string(),
|
||||
}),
|
||||
phone: z.object({
|
||||
type: z.literal("phone"),
|
||||
required: z.boolean(),
|
||||
placeholder: z.string(),
|
||||
}),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export type SystemField = z.infer<typeof SystemFieldsSchema>;
|
||||
|
||||
export type CommonField = z.infer<typeof CommonFieldsSchema>;
|
||||
|
||||
const OptionSchema = z.object({
|
||||
label: z.string(),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
const BookingFieldSchema = CommonFieldsSchema.extend({
|
||||
options: z.array(OptionSchema).optional(),
|
||||
});
|
||||
export type OptionsField = z.infer<typeof BookingFieldSchema>;
|
||||
|
||||
export const BookingFieldsSchema = z.array(BookingFieldSchema);
|
||||
|
||||
export { transformApiEventTypeLocations, transformApiEventTypeBookingFields };
|
||||
@@ -0,0 +1,568 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type {
|
||||
AddressLocation_2024_06_14,
|
||||
LinkLocation_2024_06_14,
|
||||
PhoneLocation_2024_06_14,
|
||||
IntegrationLocation_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import type { CommonField, OptionsField } from "./api-request";
|
||||
import { getResponseEventTypeLocations, getResponseEventTypeBookingFields } from "./api-response";
|
||||
|
||||
describe("getResponseEventTypeLocations", () => {
|
||||
it("should reverse transform address location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "inPerson",
|
||||
address: "1234 Main St",
|
||||
displayLocationPublicly: true,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: AddressLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "address",
|
||||
address: "1234 Main St",
|
||||
public: true,
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeLocations(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform link location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "link",
|
||||
link: "https://example.com",
|
||||
displayLocationPublicly: true,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: LinkLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "link",
|
||||
link: "https://example.com",
|
||||
public: true,
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeLocations(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform phone location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "userPhone",
|
||||
hostPhoneNumber: "123456789",
|
||||
displayLocationPublicly: true,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: PhoneLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "phone",
|
||||
phone: "123456789",
|
||||
public: true,
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeLocations(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform integration location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "integrations:daily",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: IntegrationLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "integration",
|
||||
integration: "cal-video",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeLocations(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getResponseEventTypeBookingFields", () => {
|
||||
it("should reverse transform name field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-name",
|
||||
type: "name",
|
||||
label: "Your name",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "alice",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "name",
|
||||
slug: "your-name",
|
||||
label: "Your name",
|
||||
required: true,
|
||||
placeholder: "alice",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform email field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-email",
|
||||
type: "email",
|
||||
label: "Your email",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "[email protected]",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "email",
|
||||
slug: "your-email",
|
||||
label: "Your email",
|
||||
required: true,
|
||||
placeholder: "[email protected]",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform phone field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-phone",
|
||||
type: "phone",
|
||||
label: "Your phone number",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "123456789",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "phone",
|
||||
slug: "your-phone",
|
||||
label: "Your phone number",
|
||||
required: true,
|
||||
placeholder: "123456789",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform address field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-address",
|
||||
type: "address",
|
||||
label: "Your address",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "1234 Main St",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "address",
|
||||
slug: "your-address",
|
||||
label: "Your address",
|
||||
required: true,
|
||||
placeholder: "1234 Main St",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform text field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-text",
|
||||
type: "text",
|
||||
label: "Your text",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "Enter your text",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "text",
|
||||
slug: "your-text",
|
||||
label: "Your text",
|
||||
required: true,
|
||||
placeholder: "Enter your text",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform number field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-number",
|
||||
type: "number",
|
||||
label: "Your number",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "100",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "number",
|
||||
slug: "your-number",
|
||||
label: "Your number",
|
||||
required: true,
|
||||
placeholder: "100",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform textarea field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-textarea",
|
||||
type: "textarea",
|
||||
label: "Your detailed information",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "Detailed description here...",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "textarea",
|
||||
slug: "your-textarea",
|
||||
label: "Your detailed information",
|
||||
required: true,
|
||||
placeholder: "Detailed description here...",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform select field", () => {
|
||||
const transformedField: OptionsField[] = [
|
||||
{
|
||||
name: "your-select",
|
||||
type: "select",
|
||||
label: "Your selection",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "Select...",
|
||||
options: [
|
||||
{ label: "Option 1", value: "Option 1" },
|
||||
{ label: "Option 2", value: "Option 2" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "select",
|
||||
slug: "your-select",
|
||||
label: "Your selection",
|
||||
required: true,
|
||||
placeholder: "Select...",
|
||||
options: ["Option 1", "Option 2"],
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform multiselect field", () => {
|
||||
const transformedField: OptionsField[] = [
|
||||
{
|
||||
name: "your-multiselect",
|
||||
type: "multiselect",
|
||||
label: "Your multiple selections",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
options: [
|
||||
{ label: "Option 1", value: "Option 1" },
|
||||
{ label: "Option 2", value: "Option 2" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "multiselect",
|
||||
slug: "your-multiselect",
|
||||
label: "Your multiple selections",
|
||||
required: true,
|
||||
options: ["Option 1", "Option 2"],
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform multiemail field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "your-multiemail",
|
||||
type: "multiemail",
|
||||
label: "Your multiple emails",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "[email protected]",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "multiemail",
|
||||
slug: "your-multiemail",
|
||||
label: "Your multiple emails",
|
||||
required: true,
|
||||
placeholder: "[email protected]",
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform checkbox field", () => {
|
||||
const transformedField: OptionsField[] = [
|
||||
{
|
||||
name: "your-checkbox",
|
||||
type: "checkbox",
|
||||
label: "Your checkboxes",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
options: [
|
||||
{ label: "Checkbox 1", value: "Checkbox 1" },
|
||||
{ label: "Checkbox 2", value: "Checkbox 2" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "checkbox",
|
||||
slug: "your-checkbox",
|
||||
label: "Your checkboxes",
|
||||
required: true,
|
||||
options: ["Checkbox 1", "Checkbox 2"],
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform radio field", () => {
|
||||
const transformedField: OptionsField[] = [
|
||||
{
|
||||
name: "your-radio",
|
||||
type: "radio",
|
||||
label: "Your radio buttons",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
options: [
|
||||
{ label: "Radio 1", value: "Radio 1" },
|
||||
{ label: "Radio 2", value: "Radio 2" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "radio",
|
||||
slug: "your-radio",
|
||||
label: "Your radio buttons",
|
||||
required: true,
|
||||
options: ["Radio 1", "Radio 2"],
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform boolean field", () => {
|
||||
const transformedField: CommonField[] = [
|
||||
{
|
||||
name: "agree-to-terms",
|
||||
type: "boolean",
|
||||
label: "Agree to terms?",
|
||||
sources: [
|
||||
{
|
||||
id: "user",
|
||||
type: "user",
|
||||
label: "User",
|
||||
fieldRequired: true,
|
||||
},
|
||||
],
|
||||
editable: "user",
|
||||
required: true,
|
||||
placeholder: "",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput = [
|
||||
{
|
||||
type: "boolean",
|
||||
slug: "agree-to-terms",
|
||||
label: "Agree to terms?",
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
const result = getResponseEventTypeBookingFields(transformedField);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,191 @@
|
||||
import type {
|
||||
AddressLocation_2024_06_14,
|
||||
IntegrationLocation_2024_06_14,
|
||||
LinkLocation_2024_06_14,
|
||||
PhoneLocation_2024_06_14,
|
||||
Integration_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import type { transformApiEventTypeBookingFields, transformApiEventTypeLocations } from "./api-request";
|
||||
|
||||
const reverseIntegrationsMapping: Record<string, Integration_2024_06_14> = {
|
||||
"integrations:daily": "cal-video",
|
||||
};
|
||||
|
||||
function getResponseEventTypeLocations(
|
||||
transformedLocations: ReturnType<typeof transformApiEventTypeLocations>
|
||||
) {
|
||||
if (!transformedLocations) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return transformedLocations.map((location) => {
|
||||
switch (location.type) {
|
||||
case "inPerson": {
|
||||
if (!location.address) {
|
||||
throw new Error("Address location must have an address");
|
||||
}
|
||||
const addressLocation: AddressLocation_2024_06_14 = {
|
||||
type: "address",
|
||||
address: location.address,
|
||||
public: location.displayLocationPublicly,
|
||||
};
|
||||
return addressLocation;
|
||||
}
|
||||
case "link": {
|
||||
if (!location.link) {
|
||||
throw new Error("Link location must have a link");
|
||||
}
|
||||
const linkLocation: LinkLocation_2024_06_14 = {
|
||||
type: "link",
|
||||
link: location.link,
|
||||
public: location.displayLocationPublicly,
|
||||
};
|
||||
return linkLocation;
|
||||
}
|
||||
case "userPhone": {
|
||||
if (!location.hostPhoneNumber) {
|
||||
throw new Error("Phone location must have a phone number");
|
||||
}
|
||||
const phoneLocation: PhoneLocation_2024_06_14 = {
|
||||
type: "phone",
|
||||
phone: location.hostPhoneNumber,
|
||||
public: location.displayLocationPublicly,
|
||||
};
|
||||
return phoneLocation;
|
||||
}
|
||||
default: {
|
||||
const integrationType = reverseIntegrationsMapping[location.type];
|
||||
if (!integrationType) {
|
||||
throw new Error(`Unsupported integration type '${location.type}'.`);
|
||||
}
|
||||
const integration: IntegrationLocation_2024_06_14 = {
|
||||
type: "integration",
|
||||
integration: integrationType,
|
||||
};
|
||||
return integration;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getResponseEventTypeBookingFields(
|
||||
transformedBookingFields: ReturnType<typeof transformApiEventTypeBookingFields>
|
||||
) {
|
||||
if (!transformedBookingFields) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return transformedBookingFields.map((field) => {
|
||||
switch (field.type) {
|
||||
case "name":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "email":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "phone":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "address":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "text":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "number":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "textarea":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "multiemail":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
};
|
||||
case "boolean":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
};
|
||||
case "select":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
placeholder: field.placeholder,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
};
|
||||
case "multiselect":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
};
|
||||
case "checkbox":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
};
|
||||
case "radio":
|
||||
return {
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: field.required,
|
||||
options: "options" in field ? field.options?.map((option) => option.value) : [],
|
||||
};
|
||||
default:
|
||||
throw new Error(`Unsupported booking field type '${field.type}'.`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export { getResponseEventTypeLocations, getResponseEventTypeBookingFields };
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./api-request";
|
||||
export * from "./api-response";
|
||||
@@ -4,9 +4,10 @@ import { getEventTypeAppData } from "@calcom/app-store/_utils/getEventTypeAppDat
|
||||
import type { appDataSchemas } from "@calcom/app-store/apps.schemas.generated";
|
||||
import type { appDataSchema, paymentOptionEnum } from "@calcom/app-store/stripepayment/zod";
|
||||
import type { EventTypeAppsList } from "@calcom/app-store/utils";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
|
||||
export default function getPaymentAppData(
|
||||
eventType: Parameters<typeof getEventTypeAppData>[0],
|
||||
eventType: Pick<BookerEvent, "price" | "currency" | "metadata">,
|
||||
forcedGet?: boolean
|
||||
) {
|
||||
const metadataApps = eventType?.metadata?.apps as unknown as EventTypeAppsList;
|
||||
|
||||
@@ -5,3 +5,4 @@ export * from "./isBookingLimits";
|
||||
export * from "./isDurationLimits";
|
||||
export * from "./validateIntervalLimitOrder";
|
||||
export * from "./schedules";
|
||||
export * from "./event-types";
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ import type {
|
||||
} from "@calcom/platform-types";
|
||||
import { BookerLayouts } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import { transformApiEventTypeForAtom } from "../event-types/atom-api-transformers/transformApiEventTypeForAtom";
|
||||
import { useEventType } from "../hooks/event-types/public/useEventType";
|
||||
import { useAtomsContext } from "../hooks/useAtomsContext";
|
||||
import { useAvailableSlots } from "../hooks/useAvailableSlots";
|
||||
import { useCalendarsBusyTimes } from "../hooks/useCalendarsBusyTimes";
|
||||
@@ -36,7 +38,6 @@ import {
|
||||
} from "../hooks/useGetBookingForReschedule";
|
||||
import { useHandleBookEvent } from "../hooks/useHandleBookEvent";
|
||||
import { useMe } from "../hooks/useMe";
|
||||
import { usePublicEvent } from "../hooks/usePublicEvent";
|
||||
import { useSlots } from "../hooks/useSlots";
|
||||
import { AtomsWrapper } from "../src/components/atoms-wrapper";
|
||||
|
||||
@@ -109,6 +110,7 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
|
||||
setBookingData(null);
|
||||
}
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
setSelectedDuration(props.duration ?? null);
|
||||
@@ -118,11 +120,22 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
|
||||
return getUsernameList(username ?? "").length > 1;
|
||||
}, [username]);
|
||||
|
||||
const event = usePublicEvent({
|
||||
username,
|
||||
eventSlug: props.eventSlug,
|
||||
isDynamic,
|
||||
});
|
||||
const { isSuccess, isError, isPending, data } = useEventType(username, props.eventSlug);
|
||||
|
||||
const event = useMemo(() => {
|
||||
return {
|
||||
isSuccess,
|
||||
isError,
|
||||
isPending,
|
||||
data: data && data.length > 0 ? transformApiEventTypeForAtom(data[0], props.entity) : undefined,
|
||||
};
|
||||
}, [isSuccess, isError, isPending, data, props.entity]);
|
||||
|
||||
if (isDynamic && props.duration && event.data) {
|
||||
// note(Lauris): Mandatory - In case of "dynamic" event type default event duration returned by the API is 30,
|
||||
// but we are re-using the dynamic event type as a team event, so we must set the event length to whatever the event length is.
|
||||
event.data.length = props.duration;
|
||||
}
|
||||
|
||||
const bookerLayout = useBookerLayout(event.data);
|
||||
useInitializeBookerStore({
|
||||
@@ -322,7 +335,7 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
|
||||
onClickOverlayContinue={function (): void {
|
||||
throw new Error("Function not implemented.");
|
||||
}}
|
||||
onOverlaySwitchStateChange={function (state: boolean): void {
|
||||
onOverlaySwitchStateChange={function (): void {
|
||||
throw new Error("Function not implemented.");
|
||||
}}
|
||||
extraOptions={extraOptions ?? {}}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
|
||||
import type { API_VERSIONS_ENUM } from "@calcom/platform-constants";
|
||||
import { VERSION_2024_06_11 } from "@calcom/platform-constants";
|
||||
import { VERSION_2024_06_14 } from "@calcom/platform-constants";
|
||||
|
||||
import http from "../lib/http";
|
||||
import { BaseCalProvider } from "./BaseCalProvider";
|
||||
@@ -40,7 +40,7 @@ export function CalProvider({
|
||||
children,
|
||||
autoUpdateTimezone = true,
|
||||
onTimezoneChange,
|
||||
version = VERSION_2024_06_11,
|
||||
version = VERSION_2024_06_14,
|
||||
}: CalProviderProps) {
|
||||
useEffect(() => {
|
||||
http.setVersionHeader(version);
|
||||
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
import type { BookerProps } from "@calcom/features/bookings/Booker";
|
||||
import { getFieldIdentifier } from "@calcom/features/form-builder/utils/getFieldIdentifier";
|
||||
import { defaultEvents } from "@calcom/lib/defaultEvents";
|
||||
import type { CommonField, OptionsField, SystemField } from "@calcom/lib/event-types/transformers";
|
||||
import {
|
||||
transformApiEventTypeLocations,
|
||||
transformApiEventTypeBookingFields,
|
||||
} from "@calcom/lib/event-types/transformers";
|
||||
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
|
||||
import type { EventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
||||
import {
|
||||
bookerLayoutOptions,
|
||||
BookerLayouts,
|
||||
bookerLayouts as bookerLayoutsSchema,
|
||||
userMetadata as userMetadataSchema,
|
||||
eventTypeBookingFields,
|
||||
} from "@calcom/prisma/zod-utils";
|
||||
|
||||
export function transformApiEventTypeForAtom(
|
||||
eventType: Omit<EventTypeOutput_2024_06_14, "ownerId">,
|
||||
entity: BookerProps["entity"] | undefined
|
||||
) {
|
||||
const { lengthInMinutes, locations, bookingFields, users, ...rest } = eventType;
|
||||
|
||||
const isDefault = isDefaultEvent(rest.title);
|
||||
const user = users[0];
|
||||
|
||||
const defaultEventBookerLayouts = {
|
||||
enabledLayouts: [...bookerLayoutOptions],
|
||||
defaultLayout: BookerLayouts.MONTH_VIEW,
|
||||
};
|
||||
const firstUsersMetadata = userMetadataSchema.parse(user.metadata || {});
|
||||
const bookerLayouts = bookerLayoutsSchema.parse(
|
||||
firstUsersMetadata?.defaultBookerLayouts || defaultEventBookerLayouts
|
||||
);
|
||||
|
||||
return {
|
||||
...rest,
|
||||
length: lengthInMinutes,
|
||||
locations: getLocations(locations),
|
||||
bookingFields: getBookingFields(bookingFields),
|
||||
isDefault,
|
||||
isDynamic: false,
|
||||
profile: {
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
weekStart: user.weekStart,
|
||||
image: "",
|
||||
brandColor: user.brandColor,
|
||||
darkBrandColor: user.darkBrandColor,
|
||||
theme: null,
|
||||
bookerLayouts,
|
||||
},
|
||||
entity: entity
|
||||
? {
|
||||
...entity,
|
||||
orgSlug: entity.orgSlug || null,
|
||||
teamSlug: entity.teamSlug || null,
|
||||
fromRedirectOfNonOrgLink: true,
|
||||
name: entity.name || null,
|
||||
logoUrl: entity.logoUrl || undefined,
|
||||
}
|
||||
: {
|
||||
fromRedirectOfNonOrgLink: true,
|
||||
considerUnpublished: false,
|
||||
orgSlug: null,
|
||||
teamSlug: null,
|
||||
name: null,
|
||||
logoUrl: undefined,
|
||||
},
|
||||
hosts: [],
|
||||
users: users.map((user) => ({
|
||||
...user,
|
||||
metadata: undefined,
|
||||
bookerUrl: getBookerBaseUrlSync(null),
|
||||
profile: {
|
||||
username: user.username || "",
|
||||
name: user.name,
|
||||
weekStart: user.weekStart,
|
||||
image: "",
|
||||
brandColor: user.brandColor,
|
||||
darkBrandColor: user.darkBrandColor,
|
||||
theme: null,
|
||||
organization: null,
|
||||
id: user.id,
|
||||
organizationId: null,
|
||||
userId: user.id,
|
||||
upId: `usr-${user.id}`,
|
||||
},
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
function isDefaultEvent(eventSlug: string) {
|
||||
const foundInDefaults = defaultEvents.find((obj) => {
|
||||
return obj.slug === eventSlug;
|
||||
});
|
||||
return !!foundInDefaults;
|
||||
}
|
||||
|
||||
function getLocations(locations: EventTypeOutput_2024_06_14["locations"]) {
|
||||
const transformed = transformApiEventTypeLocations(locations);
|
||||
|
||||
const withPrivateHidden = transformed.map((location) => {
|
||||
const { displayLocationPublicly, type } = location;
|
||||
|
||||
switch (type) {
|
||||
case "address":
|
||||
return displayLocationPublicly ? location : { ...location, address: "" };
|
||||
case "link":
|
||||
return displayLocationPublicly ? location : { ...location, link: "" };
|
||||
case "phone":
|
||||
return displayLocationPublicly
|
||||
? location
|
||||
: {
|
||||
...location,
|
||||
hostPhoneNumber: "",
|
||||
};
|
||||
default:
|
||||
return location;
|
||||
}
|
||||
});
|
||||
|
||||
return withPrivateHidden;
|
||||
}
|
||||
|
||||
function getBookingFields(bookingFields: EventTypeOutput_2024_06_14["bookingFields"]) {
|
||||
const transformedBookingFields: (CommonField | SystemField | OptionsField)[] =
|
||||
transformApiEventTypeBookingFields(bookingFields);
|
||||
|
||||
// These fields should be added before other user fields
|
||||
const systemBeforeFields: SystemField[] = [
|
||||
{
|
||||
type: "name",
|
||||
// This is the `name` of the main field
|
||||
name: "name",
|
||||
editable: "system",
|
||||
// This Label is used in Email only as of now.
|
||||
defaultLabel: "your_name",
|
||||
required: true,
|
||||
sources: [
|
||||
{
|
||||
label: "Default",
|
||||
id: "default",
|
||||
type: "default",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultLabel: "email_address",
|
||||
type: "email",
|
||||
name: "email",
|
||||
required: true,
|
||||
editable: "system",
|
||||
sources: [
|
||||
{
|
||||
label: "Default",
|
||||
id: "default",
|
||||
type: "default",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultLabel: "location",
|
||||
type: "radioInput",
|
||||
name: "location",
|
||||
editable: "system",
|
||||
hideWhenJustOneOption: true,
|
||||
required: false,
|
||||
getOptionsAt: "locations",
|
||||
optionsInputs: {
|
||||
attendeeInPerson: {
|
||||
type: "address",
|
||||
required: true,
|
||||
placeholder: "",
|
||||
},
|
||||
phone: {
|
||||
type: "phone",
|
||||
required: true,
|
||||
placeholder: "",
|
||||
},
|
||||
},
|
||||
sources: [
|
||||
{
|
||||
label: "Default",
|
||||
id: "default",
|
||||
type: "default",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// These fields should be added after other user fields
|
||||
const systemAfterFields: SystemField[] = [
|
||||
{
|
||||
defaultLabel: "reason_for_reschedule",
|
||||
type: "textarea",
|
||||
editable: "system-but-optional",
|
||||
name: "rescheduleReason",
|
||||
defaultPlaceholder: "reschedule_placeholder",
|
||||
required: false,
|
||||
views: [
|
||||
{
|
||||
id: "reschedule",
|
||||
label: "Reschedule View",
|
||||
},
|
||||
],
|
||||
sources: [
|
||||
{
|
||||
label: "Default",
|
||||
id: "default",
|
||||
type: "default",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const missingSystemBeforeFields: SystemField[] = [];
|
||||
|
||||
for (const field of systemBeforeFields) {
|
||||
const existingBookingFieldIndex = transformedBookingFields.findIndex(
|
||||
(f) => getFieldIdentifier(f.name) === getFieldIdentifier(field.name)
|
||||
);
|
||||
// Only do a push, we must not update existing system fields as user could have modified any property in it,
|
||||
if (existingBookingFieldIndex === -1) {
|
||||
missingSystemBeforeFields.push(field);
|
||||
} else {
|
||||
// Adding the fields from Code first and then fields from DB. Allows, the code to push new properties to the field
|
||||
transformedBookingFields[existingBookingFieldIndex] = {
|
||||
...field,
|
||||
...transformedBookingFields[existingBookingFieldIndex],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
transformedBookingFields.push(...missingSystemBeforeFields);
|
||||
|
||||
const missingSystemAfterFields: SystemField[] = [];
|
||||
for (const field of systemAfterFields) {
|
||||
const existingBookingFieldIndex = transformedBookingFields.findIndex(
|
||||
(f) => getFieldIdentifier(f.name) === getFieldIdentifier(field.name)
|
||||
);
|
||||
// Only do a push, we must not update existing system fields as user could have modified any property in it,
|
||||
if (existingBookingFieldIndex === -1) {
|
||||
missingSystemAfterFields.push(field);
|
||||
} else {
|
||||
transformedBookingFields[existingBookingFieldIndex] = {
|
||||
// Adding the fields from Code first and then fields from DB. Allows, the code to push new properties to the field
|
||||
...field,
|
||||
...transformedBookingFields[existingBookingFieldIndex],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
transformedBookingFields.push(...missingSystemAfterFields);
|
||||
return eventTypeBookingFields.brand<"HAS_SYSTEM_FIELDS">().parse(transformedBookingFields);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { EventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-event-by-id";
|
||||
export const useEventTypeById = (id: number | null) => {
|
||||
const pathname = `/${V2_ENDPOINTS.eventTypes}/${id}`;
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY, id],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<EventTypeOutput_2024_06_14>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<EventTypeOutput_2024_06_14>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMemo } from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { getUsernameList } from "@calcom/lib/defaultEvents";
|
||||
import { SUCCESS_STATUS, V2_ENDPOINTS } from "@calcom/platform-constants";
|
||||
import type { EventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
||||
import type { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-event-type";
|
||||
export type UsePublicEventReturnType = ReturnType<typeof useEventType>;
|
||||
|
||||
export const useEventType = (username: string, eventSlug: string) => {
|
||||
const [stateUsername, stateEventSlug] = useBookerStore(
|
||||
(state) => [state.username, state.eventSlug],
|
||||
shallow
|
||||
);
|
||||
|
||||
const requestUsername = stateUsername ?? username;
|
||||
const requestEventSlug = stateEventSlug ?? eventSlug;
|
||||
|
||||
const isDynamic = useMemo(() => {
|
||||
return getUsernameList(requestUsername ?? "").length > 1;
|
||||
}, [requestUsername]);
|
||||
|
||||
const event = useQuery({
|
||||
queryKey: [QUERY_KEY, stateUsername ?? username, stateEventSlug ?? eventSlug],
|
||||
queryFn: async () => {
|
||||
if (isDynamic) {
|
||||
return http
|
||||
.get<ApiResponse<EventTypeOutput_2024_06_14[]>>(
|
||||
`/${V2_ENDPOINTS.eventTypes}?usernames=${encodeURIComponent(getUsernameList(username).join(","))}`
|
||||
)
|
||||
.then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return res.data.data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
}
|
||||
|
||||
return http
|
||||
.get<ApiResponse<EventTypeOutput_2024_06_14[]>>(
|
||||
`/${V2_ENDPOINTS.eventTypes}?username=${requestUsername}&eventSlug=${requestEventSlug}`
|
||||
)
|
||||
.then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return res.data.data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return event;
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { EventTypeOutput_2024_06_14 } from "@calcom/platform-types";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "use-event-types";
|
||||
export const useEventTypes = (username: string) => {
|
||||
const pathname = `/${V2_ENDPOINTS.eventTypes}?username=${username}`;
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY, username],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<EventTypeOutput_2024_06_14[]>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<EventTypeOutput_2024_06_14[]>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { EventTypesByViewer } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "get-private-events";
|
||||
export const useEventTypesPrivate = () => {
|
||||
const pathname = `/${V2_ENDPOINTS.eventTypes}`;
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<EventTypesByViewer>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<EventTypesByViewer>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { EventTypesPublic } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "get-public-events";
|
||||
export const useEventTypesPublic = (username: string) => {
|
||||
const pathname = `/${V2_ENDPOINTS.eventTypes}/${username}/public`;
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY, username],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<EventTypesPublic>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<EventTypesPublic>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { EventType as AtomEventType } from "@calcom/platform-libraries";
|
||||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
||||
|
||||
import http from "../../lib/http";
|
||||
|
||||
export const QUERY_KEY = "get-event-by-id";
|
||||
export const useGetEventTypeById = (id: number | null) => {
|
||||
const pathname = `/${V2_ENDPOINTS.eventTypes}/${id}?for=atom`;
|
||||
|
||||
return useQuery({
|
||||
queryKey: [QUERY_KEY, id],
|
||||
queryFn: () => {
|
||||
return http?.get<ApiResponse<AtomEventType>>(pathname).then((res) => {
|
||||
if (res.data.status === SUCCESS_STATUS) {
|
||||
return (res.data as ApiSuccessResponse<AtomEventType>).data;
|
||||
}
|
||||
throw new Error(res.data.error.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { useEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import {
|
||||
useTimePreferences,
|
||||
mapBookingToMutationInput,
|
||||
mapRecurringBookingToMutationInput,
|
||||
} from "@calcom/features/bookings/lib";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { BookingCreateBody } from "@calcom/prisma/zod-utils";
|
||||
|
||||
@@ -13,7 +13,12 @@ import type { UseCreateBookingInput } from "./useCreateBooking";
|
||||
|
||||
type UseHandleBookingProps = {
|
||||
bookingForm: UseBookingFormReturnType["bookingForm"];
|
||||
event: useEventReturnType;
|
||||
event?: {
|
||||
data?: Pick<
|
||||
BookerEvent,
|
||||
"id" | "isDynamic" | "metadata" | "recurringEvent" | "length" | "slug" | "schedulingType"
|
||||
> | null;
|
||||
};
|
||||
metadata: Record<string, string>;
|
||||
hashedLink?: string | null;
|
||||
teamMemberEmail?: string;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { shallow } from "zustand/shallow";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { useSlotReservationId } from "@calcom/features/bookings/Booker/useSlotReservationId";
|
||||
import type { useEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { MINUTES_TO_BOOK } from "@calcom/lib/constants";
|
||||
|
||||
import { useDeleteSelectedSlot } from "./useDeleteSelectedSlot";
|
||||
@@ -12,7 +12,7 @@ import { useReserveSlot } from "./useReserveSlot";
|
||||
|
||||
export type UseSlotsReturnType = ReturnType<typeof useSlots>;
|
||||
|
||||
export const useSlots = (event: useEventReturnType) => {
|
||||
export const useSlots = (event: { data?: Pick<BookerEvent, "id" | "length"> | null }) => {
|
||||
const selectedDuration = useBookerStore((state) => state.selectedDuration);
|
||||
const [selectedTimeslot, setSelectedTimeslot] = useBookerStore(
|
||||
(state) => [state.selectedTimeslot, state.setSelectedTimeslot],
|
||||
|
||||
@@ -5,9 +5,9 @@ export { BookerPlatformWrapper as Booker } from "./booker";
|
||||
export { useIsPlatform } from "./hooks/useIsPlatform";
|
||||
export { useAtomsContext } from "./hooks/useAtomsContext";
|
||||
export { useConnectedCalendars } from "./hooks/useConnectedCalendars";
|
||||
export { useEventTypesPublic } from "./hooks/event-types/useEventTypesPublic";
|
||||
export { usePublicEvent } from "./hooks/usePublicEvent";
|
||||
export { useGetEventTypeById } from "./hooks/event-types/useGetEventTypeById";
|
||||
export { useEventTypes } from "./hooks/event-types/public/useEventTypes";
|
||||
export { useEventType as useEvent } from "./hooks/event-types/public/useEventType";
|
||||
export { useEventTypeById } from "./hooks/event-types/private/useEventTypeById";
|
||||
export { useCancelBooking } from "./hooks/useCancelBooking";
|
||||
export { useGetBooking } from "./hooks/useGetBooking";
|
||||
export { useGetBookings } from "./hooks/useGetBookings";
|
||||
|
||||
@@ -3,7 +3,7 @@ export { AvailabilitySettingsWebWrapper as AvailabilitySettings } from "./availa
|
||||
export { CalProvider } from "./cal-provider/CalProvider";
|
||||
export { useIsPlatform } from "./hooks/useIsPlatform";
|
||||
export { useAtomsContext } from "./hooks/useAtomsContext";
|
||||
export { useGetEventTypeById } from "./hooks/event-types/useGetEventTypeById";
|
||||
export { useEventTypeById } from "./hooks/event-types/private/useEventTypeById";
|
||||
export { useHandleBookEvent } from "./hooks/useHandleBookEvent";
|
||||
export * as Dialog from "./src/components/ui/dialog";
|
||||
export { Timezone } from "./timezone";
|
||||
@@ -51,9 +51,12 @@ export const X_CAL_CLIENT_ID = "x-cal-client-id";
|
||||
// HTTP status codes
|
||||
export const HTTP_CODE_TOKEN_EXPIRED = 498;
|
||||
|
||||
export const VERSION_2024_06_14 = "2024-06-14";
|
||||
export const VERSION_2024_06_11 = "2024-06-11";
|
||||
export const VERSION_2024_04_15 = "2024-04-15";
|
||||
export const API_VERSIONS = [VERSION_2024_06_11, VERSION_2024_04_15] as const;
|
||||
|
||||
export const API_VERSIONS = [VERSION_2024_06_14, VERSION_2024_06_11, VERSION_2024_04_15] as const;
|
||||
|
||||
export type API_VERSIONS_ENUM = (typeof API_VERSIONS)[number];
|
||||
export type API_VERSIONS_TYPE = typeof API_VERSIONS;
|
||||
export const CAL_API_VERSION_HEADER = "cal-api-version";
|
||||
@@ -4,7 +4,7 @@ import { Inter } from "next/font/google";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
|
||||
import { Booker, useEventTypesPublic } from "@calcom/atoms";
|
||||
import { Booker, useEventTypes } from "@calcom/atoms";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function Bookings(props: { calUsername: string; calEmail: string
|
||||
const [eventTypeSlug, setEventTypeSlug] = useState<string | null>(null);
|
||||
const [eventTypeDuration, setEventTypeDuration] = useState<number | null>(null);
|
||||
const router = useRouter();
|
||||
const { isLoading: isLoadingEvents, data: eventTypes } = useEventTypesPublic(props.calUsername);
|
||||
const { isLoading: isLoadingEvents, data: eventTypes } = useEventTypes(props.calUsername);
|
||||
const rescheduleUid = (router.query.rescheduleUid as string) ?? "";
|
||||
const eventTypeSlugQueryParam = (router.query.eventTypeSlug as string) ?? "";
|
||||
|
||||
@@ -28,26 +28,28 @@ export default function Bookings(props: { calUsername: string; calEmail: string
|
||||
|
||||
{!isLoadingEvents && !eventTypeSlug && Boolean(eventTypes?.length) && !rescheduleUid && (
|
||||
<div className="flex flex-col gap-4">
|
||||
{eventTypes?.map((event: { id: number; slug: string; title: string; length: number }) => {
|
||||
const formatEventSlug = event.slug
|
||||
.split("-")
|
||||
.map((item) => `${item[0].toLocaleUpperCase()}${item.slice(1)}`)
|
||||
.join(" ");
|
||||
{eventTypes?.map(
|
||||
(event: { id: number; slug: string; title: string; lengthInMinutes: number }) => {
|
||||
const formatEventSlug = event.slug
|
||||
.split("-")
|
||||
.map((item) => `${item[0].toLocaleUpperCase()}${item.slice(1)}`)
|
||||
.join(" ");
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
setEventTypeSlug(event.slug);
|
||||
setEventTypeDuration(event.length);
|
||||
}}
|
||||
className="mx-10 w-[80vw] cursor-pointer rounded-md border-[0.8px] border-black px-10 py-4"
|
||||
key={event.id}>
|
||||
<h1 className="text-lg font-semibold">{formatEventSlug}</h1>
|
||||
<p>{`/${event.slug}`}</p>
|
||||
<span className="border-none bg-gray-800 px-2 text-white">{event?.length}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
setEventTypeSlug(event.slug);
|
||||
setEventTypeDuration(event.lengthInMinutes);
|
||||
}}
|
||||
className="mx-10 w-[80vw] cursor-pointer rounded-md border-[0.8px] border-black px-10 py-4"
|
||||
key={event.id}>
|
||||
<h1 className="text-lg font-semibold">{formatEventSlug}</h1>
|
||||
<p>{`/${event.slug}`}</p>
|
||||
<span className="border-none bg-gray-800 px-2 text-white">{event?.lengthInMinutes}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { CalendarService } from "@calcom/app-store/applecalendar/lib";
|
||||
import { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booking";
|
||||
import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo";
|
||||
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
|
||||
@@ -5,6 +6,7 @@ import * as newBookingMethods from "@calcom/features/bookings/lib/handleNewBooki
|
||||
import { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";
|
||||
import * as instantMeetingMethods from "@calcom/features/instant-meeting/handleInstantMeeting";
|
||||
import getAllUserBookings from "@calcom/lib/bookings/getAllUserBookings";
|
||||
import { symmetricEncrypt } from "@calcom/lib/crypto";
|
||||
import { updateHandler as updateScheduleHandler } from "@calcom/trpc/server/routers/viewer/availability/schedule/update.handler";
|
||||
import { getAvailableSlots } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
import { createNewUsersConnectToOrgIfExists } from "@calcom/trpc/server/routers/viewer/teams/inviteMember/utils";
|
||||
@@ -78,3 +80,20 @@ export { getBookingInfo };
|
||||
export { handleCancelBooking };
|
||||
|
||||
export { eventTypeBookingFields, eventTypeLocations } from "@calcom/prisma/zod-utils";
|
||||
|
||||
export { EventTypeMetaDataSchema, userMetadata } from "@calcom/prisma/zod-utils";
|
||||
|
||||
export {
|
||||
transformApiEventTypeBookingFields,
|
||||
transformApiEventTypeLocations,
|
||||
getResponseEventTypeLocations,
|
||||
getResponseEventTypeBookingFields,
|
||||
TransformedLocationsSchema,
|
||||
BookingFieldsSchema,
|
||||
} from "@calcom/lib/event-types/transformers";
|
||||
|
||||
export { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";
|
||||
export { dynamicEvent } from "@calcom/lib/defaultEvents";
|
||||
|
||||
export { symmetricEncrypt };
|
||||
export { CalendarService };
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./inputs";
|
||||
export * from "./outputs";
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
import { BadRequestException } from "@nestjs/common";
|
||||
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
|
||||
import { plainToInstance } from "class-transformer";
|
||||
import { IsString, IsBoolean, IsArray, IsIn, IsOptional } from "class-validator";
|
||||
import type { ValidationOptions, ValidatorConstraintInterface } from "class-validator";
|
||||
import { registerDecorator, validate, ValidatorConstraint } from "class-validator";
|
||||
|
||||
const bookingFields = [
|
||||
"name",
|
||||
"email",
|
||||
"phone",
|
||||
"address",
|
||||
"text",
|
||||
"number",
|
||||
"textarea",
|
||||
"select",
|
||||
"multiselect",
|
||||
"multiemail",
|
||||
"checkbox",
|
||||
"radio",
|
||||
"boolean",
|
||||
] as const;
|
||||
|
||||
export class NameField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "name";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
}
|
||||
export class EmailField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "email";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export class PhoneField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "phone";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export class AddressField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "address";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Please enter your address" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
@DocsProperty({ example: "e.g., 1234 Main St" })
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export class TextField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "text";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Please enter your text" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "e.g., Enter text here" })
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export class NumberField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "number";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Please enter a number" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "e.g., 100" })
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export class TextAreaField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "textarea";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Please enter detailed information" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "e.g., Detailed description here..." })
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export class SelectField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "select";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Please select an option" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Select..." })
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
|
||||
@IsArray()
|
||||
@DocsProperty({ type: [String], example: ["Option 1", "Option 2"] })
|
||||
options!: string[];
|
||||
}
|
||||
|
||||
export class MultiSelectField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "multiselect";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Please select multiple options" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsArray()
|
||||
@DocsProperty({ type: [String], example: ["Option 1", "Option 2"] })
|
||||
options!: string[];
|
||||
}
|
||||
|
||||
export class MultiEmailField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "multiemail";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Please enter multiple emails" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "e.g., [email protected]" })
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export class CheckboxGroupField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "checkbox";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Select all that apply" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsArray()
|
||||
@DocsProperty({ type: [String], example: ["Checkbox 1", "Checkbox 2"] })
|
||||
options!: string[];
|
||||
}
|
||||
|
||||
export class RadioGroupField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "radio";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Select one option" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsArray()
|
||||
@DocsProperty({ type: [String], example: ["Radio 1", "Radio 2"] })
|
||||
options!: string[];
|
||||
}
|
||||
|
||||
export class BooleanField_2024_06_14 {
|
||||
@IsIn(bookingFields)
|
||||
@DocsProperty()
|
||||
type!: "boolean";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "Agree to terms?" })
|
||||
label!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
}
|
||||
|
||||
export type BookingField_2024_06_14 =
|
||||
| NameField_2024_06_14
|
||||
| EmailField_2024_06_14
|
||||
| PhoneField_2024_06_14
|
||||
| AddressField_2024_06_14
|
||||
| TextField_2024_06_14
|
||||
| NumberField_2024_06_14
|
||||
| TextAreaField_2024_06_14
|
||||
| SelectField_2024_06_14
|
||||
| MultiSelectField_2024_06_14
|
||||
| MultiEmailField_2024_06_14
|
||||
| CheckboxGroupField_2024_06_14
|
||||
| RadioGroupField_2024_06_14
|
||||
| BooleanField_2024_06_14;
|
||||
|
||||
@ValidatorConstraint({ async: true })
|
||||
class BookingFieldValidator_2024_06_14 implements ValidatorConstraintInterface {
|
||||
private classTypeMap: { [key: string]: new () => BookingField_2024_06_14 } = {
|
||||
name: NameField_2024_06_14,
|
||||
email: EmailField_2024_06_14,
|
||||
phone: PhoneField_2024_06_14,
|
||||
address: AddressField_2024_06_14,
|
||||
text: TextField_2024_06_14,
|
||||
number: NumberField_2024_06_14,
|
||||
textarea: TextAreaField_2024_06_14,
|
||||
select: SelectField_2024_06_14,
|
||||
multiselect: MultiSelectField_2024_06_14,
|
||||
multiemail: MultiEmailField_2024_06_14,
|
||||
checkbox: CheckboxGroupField_2024_06_14,
|
||||
radio: RadioGroupField_2024_06_14,
|
||||
boolean: BooleanField_2024_06_14,
|
||||
};
|
||||
|
||||
async validate(bookingFields: { type: string; slug: string }[]) {
|
||||
if (!Array.isArray(bookingFields)) {
|
||||
throw new BadRequestException(`'bookingFields' must be an array.`);
|
||||
}
|
||||
|
||||
if (!bookingFields.length) {
|
||||
throw new BadRequestException(`'bookingFields' must contain at least 1 booking field.`);
|
||||
}
|
||||
|
||||
const slugs: string[] = [];
|
||||
for (const field of bookingFields) {
|
||||
const { type, slug } = field;
|
||||
if (!type) {
|
||||
throw new BadRequestException(`Each booking field must have a 'type' property.`);
|
||||
}
|
||||
|
||||
if (!slug) {
|
||||
throw new BadRequestException(`Each booking field must have a 'slug' property.`);
|
||||
}
|
||||
|
||||
if (slugs.includes(slug)) {
|
||||
throw new BadRequestException(
|
||||
`Duplicate bookingFields slug '${slug}' found. All bookingFields slugs must be unique.`
|
||||
);
|
||||
}
|
||||
slugs.push(slug);
|
||||
|
||||
const ClassType = this.classTypeMap[type];
|
||||
if (!ClassType) {
|
||||
throw new BadRequestException(`Unsupported booking field type '${type}'.`);
|
||||
}
|
||||
|
||||
const instance = plainToInstance(ClassType, field);
|
||||
const errors = await validate(instance);
|
||||
if (errors.length > 0) {
|
||||
const message = errors.flatMap((error) => Object.values(error.constraints || {})).join(", ");
|
||||
throw new BadRequestException(`Validation failed for ${type} booking field: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
defaultMessage() {
|
||||
return `Validation failed for one or more booking fields.`;
|
||||
}
|
||||
}
|
||||
|
||||
export function ValidateBookingFields_2024_06_14(validationOptions?: ValidationOptions) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return function (object: any, propertyName: string) {
|
||||
registerDecorator({
|
||||
name: "ValidateBookingFields",
|
||||
target: object.constructor,
|
||||
propertyName: propertyName,
|
||||
options: validationOptions,
|
||||
validator: new BookingFieldValidator_2024_06_14(),
|
||||
});
|
||||
};
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
|
||||
import { IsString, IsInt, IsBoolean, IsOptional, Min } from "class-validator";
|
||||
|
||||
import type { BookingField_2024_06_14 } from "./booking-fields.input";
|
||||
import { ValidateBookingFields_2024_06_14 } from "./booking-fields.input";
|
||||
import { ValidateLocations_2024_06_14 } from "./locations.input";
|
||||
import type { Location_2024_06_14 } from "./locations.input";
|
||||
|
||||
export const CREATE_EVENT_LENGTH_EXAMPLE = 60;
|
||||
export const CREATE_EVENT_TITLE_EXAMPLE = "Learn the secrets of masterchief!";
|
||||
export const CREATE_EVENT_DESCRIPTION_EXAMPLE =
|
||||
"Discover the culinary wonders of the Argentina by making the best flan ever!";
|
||||
export class CreateEventTypeInput_2024_06_14 {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@DocsProperty({ example: CREATE_EVENT_LENGTH_EXAMPLE })
|
||||
lengthInMinutes!: number;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: CREATE_EVENT_TITLE_EXAMPLE })
|
||||
title!: string;
|
||||
|
||||
@IsString()
|
||||
slug!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@DocsProperty({ example: CREATE_EVENT_DESCRIPTION_EXAMPLE })
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateLocations_2024_06_14()
|
||||
locations?: Location_2024_06_14[];
|
||||
|
||||
@IsOptional()
|
||||
@ValidateBookingFields_2024_06_14()
|
||||
bookingFields?: BookingField_2024_06_14[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
disableGuests?: boolean;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
slotInterval?: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@IsOptional()
|
||||
minimumBookingNotice?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
beforeEventBuffer?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
afterEventBuffer?: number;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export enum Editable {
|
||||
system = "system",
|
||||
systemButOptional = "system-but-optional",
|
||||
systemButHidden = "system-but-hidden",
|
||||
user = "user",
|
||||
userReadonly = "user-readonly",
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
export enum BaseFieldEnum {
|
||||
name = "name",
|
||||
number = "number",
|
||||
boolean = "boolean",
|
||||
address = "address",
|
||||
text = "text",
|
||||
textarea = "textarea",
|
||||
email = "email",
|
||||
phone = "phone",
|
||||
multiemail = "multiemail",
|
||||
select = "select",
|
||||
multiselect = "multiselect",
|
||||
checkbox = "checkbox",
|
||||
radio = "radio",
|
||||
radioInput = "radioInput",
|
||||
}
|
||||
|
||||
export type BaseFieldType = keyof typeof BaseFieldEnum;
|
||||
@@ -0,0 +1,9 @@
|
||||
export enum Frequency {
|
||||
YEARLY = 0,
|
||||
MONTHLY = 1,
|
||||
WEEKLY = 2,
|
||||
DAILY = 3,
|
||||
HOURLY = 4,
|
||||
MINUTELY = 5,
|
||||
SECONDLY = 6,
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export enum PeriodType {
|
||||
UNLIMITED = "UNLIMITED",
|
||||
ROLLING = "ROLLING",
|
||||
RANGE = "RANGE",
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export enum SchedulingType {
|
||||
ROUND_ROBIN = "ROUND_ROBIN",
|
||||
COLLECTIVE = "COLLECTIVE",
|
||||
MANAGED = "MANAGED",
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { Transform } from "class-transformer";
|
||||
import { IsOptional, IsString } from "class-validator";
|
||||
|
||||
export class GetEventTypesQuery_2024_06_14 {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
username?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
eventSlug?: string;
|
||||
|
||||
@IsOptional()
|
||||
@TransformUsernames()
|
||||
usernames?: string[];
|
||||
}
|
||||
|
||||
function TransformUsernames() {
|
||||
return Transform(({ value }) => {
|
||||
if (typeof value === "string") {
|
||||
return value.split(",").map((username) => username.trim());
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export * from "./create-event-type.input";
|
||||
export * from "./locations.input";
|
||||
export * from "./booking-fields.input";
|
||||
export * from "./recurring-event.input";
|
||||
export * from "./update-event-type.input";
|
||||
export * from "./get-event-types-query.input";
|
||||
@@ -0,0 +1,122 @@
|
||||
import { BadRequestException } from "@nestjs/common";
|
||||
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
|
||||
import { plainToInstance } from "class-transformer";
|
||||
import { IsString, IsUrl, IsIn, IsPhoneNumber, IsBoolean } from "class-validator";
|
||||
import type { ValidationOptions, ValidatorConstraintInterface } from "class-validator";
|
||||
import { registerDecorator, validate, ValidatorConstraint } from "class-validator";
|
||||
|
||||
const locations = ["address", "link", "integration", "phone"] as const;
|
||||
|
||||
export class AddressLocation_2024_06_14 {
|
||||
@IsIn(locations)
|
||||
type!: "address";
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: "123 Example St, City, Country" })
|
||||
address!: string;
|
||||
|
||||
@IsBoolean()
|
||||
public!: boolean;
|
||||
}
|
||||
|
||||
export class LinkLocation_2024_06_14 {
|
||||
@IsIn(locations)
|
||||
type!: "link";
|
||||
|
||||
@IsUrl()
|
||||
@DocsProperty({ example: "https://customvideo.com/join/123456" })
|
||||
link!: string;
|
||||
|
||||
@IsBoolean()
|
||||
public!: boolean;
|
||||
}
|
||||
|
||||
const integrations = ["cal-video"] as const;
|
||||
export type Integration_2024_06_14 = (typeof integrations)[number];
|
||||
|
||||
export class IntegrationLocation_2024_06_14 {
|
||||
@IsIn(locations)
|
||||
type!: "integration";
|
||||
|
||||
@IsIn(integrations)
|
||||
@DocsProperty({ example: integrations[0] })
|
||||
integration!: Integration_2024_06_14;
|
||||
}
|
||||
|
||||
export class PhoneLocation_2024_06_14 {
|
||||
@IsIn(locations)
|
||||
type!: "phone";
|
||||
|
||||
@IsPhoneNumber()
|
||||
@DocsProperty({ example: "+37120993151" })
|
||||
phone!: string;
|
||||
|
||||
@IsBoolean()
|
||||
public!: boolean;
|
||||
}
|
||||
|
||||
export type Location_2024_06_14 =
|
||||
| AddressLocation_2024_06_14
|
||||
| LinkLocation_2024_06_14
|
||||
| IntegrationLocation_2024_06_14
|
||||
| PhoneLocation_2024_06_14;
|
||||
|
||||
@ValidatorConstraint({ async: true })
|
||||
class LocationValidator_2024_06_14 implements ValidatorConstraintInterface {
|
||||
private classTypeMap: { [key: string]: new () => Location_2024_06_14 } = {
|
||||
address: AddressLocation_2024_06_14,
|
||||
link: LinkLocation_2024_06_14,
|
||||
integration: IntegrationLocation_2024_06_14,
|
||||
phone: PhoneLocation_2024_06_14,
|
||||
};
|
||||
|
||||
async validate(locations: { type: string }[]) {
|
||||
if (!Array.isArray(locations)) {
|
||||
throw new BadRequestException(`'locations' must be an array.`);
|
||||
}
|
||||
|
||||
if (!locations.length) {
|
||||
throw new BadRequestException(`'locations' must contain at least 1 location.`);
|
||||
}
|
||||
|
||||
for (const location of locations) {
|
||||
const { type } = location;
|
||||
if (!type) {
|
||||
throw new BadRequestException(`Each object in 'locations' must have a 'type' property.`);
|
||||
}
|
||||
|
||||
const ClassType = this.classTypeMap[type];
|
||||
if (!ClassType) {
|
||||
throw new BadRequestException(
|
||||
`Unsupported location type '${type}'. Valid types are address, link, integration, and phone.`
|
||||
);
|
||||
}
|
||||
|
||||
const instance = plainToInstance(ClassType, location);
|
||||
const errors = await validate(instance);
|
||||
if (errors.length > 0) {
|
||||
const message = errors.flatMap((error) => Object.values(error.constraints || {})).join(", ");
|
||||
throw new BadRequestException(`Validation failed for ${type} location: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
defaultMessage() {
|
||||
return `Validation failed for one or more location entries.`;
|
||||
}
|
||||
}
|
||||
|
||||
export function ValidateLocations_2024_06_14(validationOptions?: ValidationOptions) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return function (object: any, propertyName: string) {
|
||||
registerDecorator({
|
||||
name: "ValidateLocation",
|
||||
target: object.constructor,
|
||||
propertyName: propertyName,
|
||||
options: validationOptions,
|
||||
validator: new LocationValidator_2024_06_14(),
|
||||
});
|
||||
};
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { IsInt, IsEnum, IsOptional, IsString, IsDateString } from "class-validator";
|
||||
|
||||
export enum Frequency {
|
||||
YEARLY = 0,
|
||||
MONTHLY = 1,
|
||||
WEEKLY = 2,
|
||||
DAILY = 3,
|
||||
HOURLY = 4,
|
||||
MINUTELY = 5,
|
||||
SECONDLY = 6,
|
||||
}
|
||||
|
||||
export class RecurringEvent_2024_06_14 {
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
dtstart?: Date;
|
||||
|
||||
@IsInt()
|
||||
interval!: number;
|
||||
|
||||
@IsInt()
|
||||
count!: number;
|
||||
|
||||
@IsEnum(Frequency)
|
||||
freq!: Frequency;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
until?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
tzid?: string;
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import { IsString, IsInt, IsBoolean, IsOptional, Min } from "class-validator";
|
||||
|
||||
import type { BookingField_2024_06_14 } from "./booking-fields.input";
|
||||
import { ValidateBookingFields_2024_06_14 } from "./booking-fields.input";
|
||||
import { ValidateLocations_2024_06_14 } from "./locations.input";
|
||||
import type { Location_2024_06_14 } from "./locations.input";
|
||||
|
||||
export class UpdateEventTypeInput_2024_06_14 {
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
lengthInMinutes?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
title?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateLocations_2024_06_14()
|
||||
locations?: Location_2024_06_14[];
|
||||
|
||||
@IsOptional()
|
||||
@ValidateBookingFields_2024_06_14()
|
||||
bookingFields?: BookingField_2024_06_14[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
disableGuests?: boolean;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
slotInterval?: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@IsOptional()
|
||||
minimumBookingNotice?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
beforeEventBuffer?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
afterEventBuffer?: number;
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
|
||||
import { Type } from "class-transformer";
|
||||
import { IsBoolean, IsEnum, IsInt, IsOptional, IsString, Min } from "class-validator";
|
||||
|
||||
import type { Location_2024_06_14, BookingField_2024_06_14 } from "../inputs";
|
||||
import { RecurringEvent_2024_06_14 } from "../inputs";
|
||||
import { ValidateBookingFields_2024_06_14 } from "../inputs/booking-fields.input";
|
||||
import { ValidateLocations_2024_06_14 } from "../inputs/locations.input";
|
||||
|
||||
enum SchedulingTypeEnum {
|
||||
ROUND_ROBIN = "ROUND_ROBIN",
|
||||
COLLECTIVE = "COLLECTIVE",
|
||||
MANAGED = "MANAGED",
|
||||
}
|
||||
|
||||
export type SchedulingType = "ROUND_ROBIN" | "COLLECTIVE" | "MANAGED";
|
||||
|
||||
class Schedule_2024_06_14 {
|
||||
@IsInt()
|
||||
id!: number;
|
||||
|
||||
@IsString()
|
||||
timeZone!: string | null;
|
||||
}
|
||||
|
||||
class User_2024_06_14 {
|
||||
@IsInt()
|
||||
id!: number;
|
||||
|
||||
@IsString()
|
||||
name!: string | null;
|
||||
|
||||
@IsString()
|
||||
username!: string | null;
|
||||
|
||||
@IsString()
|
||||
avatarUrl!: string | null;
|
||||
|
||||
@IsString()
|
||||
weekStart!: string;
|
||||
|
||||
@IsString()
|
||||
brandColor!: string | null;
|
||||
|
||||
@IsString()
|
||||
darkBrandColor!: string | null;
|
||||
|
||||
metadata!: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class EventTypeOutput_2024_06_14 {
|
||||
@IsInt()
|
||||
@DocsProperty({ example: 1 })
|
||||
id!: number;
|
||||
|
||||
@IsInt()
|
||||
ownerId!: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
lengthInMinutes!: number;
|
||||
|
||||
@IsString()
|
||||
title!: string;
|
||||
|
||||
@IsString()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
description!: string;
|
||||
|
||||
@ValidateLocations_2024_06_14()
|
||||
locations!: Location_2024_06_14[];
|
||||
|
||||
@ValidateBookingFields_2024_06_14()
|
||||
bookingFields!: BookingField_2024_06_14[];
|
||||
|
||||
@IsBoolean()
|
||||
disableGuests!: boolean;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
slotInterval?: number | null;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@IsOptional()
|
||||
minimumBookingNotice?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
beforeEventBuffer?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
afterEventBuffer?: number;
|
||||
|
||||
@IsEnum(SchedulingTypeEnum)
|
||||
schedulingType!: SchedulingType | null;
|
||||
|
||||
@Type(() => RecurringEvent_2024_06_14)
|
||||
recurringEvent!: RecurringEvent_2024_06_14 | null;
|
||||
|
||||
@Type(() => Object)
|
||||
metadata!: Record<string, unknown>;
|
||||
|
||||
@IsBoolean()
|
||||
requiresConfirmation!: boolean;
|
||||
|
||||
@IsInt()
|
||||
price!: number;
|
||||
|
||||
@IsString()
|
||||
currency!: string;
|
||||
|
||||
@IsBoolean()
|
||||
lockTimeZoneToggleOnBookingPage!: boolean;
|
||||
|
||||
@IsInt()
|
||||
seatsPerTimeSlot!: number | null;
|
||||
|
||||
@IsBoolean()
|
||||
forwardParamsSuccessRedirect!: boolean | null;
|
||||
|
||||
@IsString()
|
||||
successRedirectUrl!: string | null;
|
||||
|
||||
@IsBoolean()
|
||||
seatsShowAvailabilityCount!: boolean | null;
|
||||
|
||||
@IsBoolean()
|
||||
isInstantEvent!: boolean;
|
||||
|
||||
users!: User_2024_06_14[];
|
||||
|
||||
schedule!: Schedule_2024_06_14 | null;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./event-type.output";
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./event-types_2024_06_14";
|
||||
@@ -6,3 +6,4 @@ export * from "./calendars";
|
||||
export * from "./bookings";
|
||||
export * from "./billing";
|
||||
export * from "./schedules";
|
||||
export * from "./event-types";
|
||||
@@ -3,13 +3,11 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
|
||||
import type { Team, User } from "@calcom/prisma/client";
|
||||
import type { UserProfile } from "@calcom/types/UserProfile";
|
||||
import { AvatarGroup } from "@calcom/ui";
|
||||
|
||||
type UserAvatarProps = Omit<React.ComponentProps<typeof AvatarGroup>, "items"> & {
|
||||
users: (Pick<User, "name" | "username" | "avatarUrl"> & {
|
||||
bookerUrl: string;
|
||||
profile: UserProfile;
|
||||
})[];
|
||||
organization: Pick<Team, "slug" | "name">;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user