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
@@ -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 };
|
||||
|
||||
Reference in new issue
Block a user