refactor: move Booker hooks from packages/features to apps/web/modules (#27343)
* refactor: move Booker hooks from packages/features to apps/web/modules Migrate the following Booker hooks: - useOverlayCalendar - useSkipConfirmStep - useInitializeWeekStart - useIsQuickAvailabilityCheckFeatureEnabled - useDecoyBooking These hooks are only imported by apps/web files, making them safe to move without creating circular dependencies. Part of the tRPC-driven UI migration from packages/features to apps/web/modules. Co-Authored-By: [email protected] <[email protected]> * fix: revert useIsQuickAvailabilityCheckFeatureEnabled move and fix import paths - Reverted useIsQuickAvailabilityCheckFeatureEnabled.ts back to packages/features since it's imported by useSlots.ts in packages/features (would create circular dependency) - Fixed import paths in useOverlayCalendar.ts to use @calcom/features paths - Fixed import paths in useSkipConfirmStep.ts to use @calcom/features paths - Updated Booker.tsx to import useIsQuickAvailabilityCheckFeatureEnabled from original location Co-Authored-By: [email protected] <[email protected]> * fix: use @calcom/web alias for hook imports to fix vitest resolution Co-Authored-By: [email protected] <[email protected]> * refactor * migrate more hooks * fix * mv types * fix * fix * fix * fix * revert: remove formatting-only changes to make PR easier to review Co-Authored-By: [email protected] <[email protected]> * fix * fix * fix * revert: restore original import ordering in moved hooks Co-Authored-By: [email protected] <[email protected]> * fix imports * fix * fix * wip * wip * wip * wip * wip * wip * fix: add isBrowser guard to useSlotsViewOnSmallScreen hook Address Cubic AI review feedback (confidence 9/10) by adding the isBrowser guard to the useSlotsViewOnSmallScreen hook to follow the file's client-only contract and avoid executing during SSR/prerendering. Co-Authored-By: unknown <> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
46 files changed
+214
-214
No files matched your search
@@ -6,7 +6,7 @@ import {
|
||||
AvailableTimesSkeleton,
|
||||
} from "@calcom/web/modules/bookings/components/AvailableTimes";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import type { IUseBookingLoadingStates } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
|
||||
import type { IUseBookingLoadingStates } from "../hooks/useBookings";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import type { Slot } from "@calcom/features/schedules/lib/use-schedule/types";
|
||||
import { useNonEmptyScheduleDays } from "@calcom/features/schedules/lib/use-schedule/useNonEmptyScheduleDays";
|
||||
|
||||
@@ -9,7 +9,7 @@ import dayjs from "@calcom/dayjs";
|
||||
import type { IOutOfOfficeData } from "@calcom/features/availability/lib/getUserAvailability";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { OutOfOfficeInSlots } from "./OutOfOfficeInSlots";
|
||||
import type { IUseBookingLoadingStates } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
|
||||
import type { IUseBookingLoadingStates } from "../hooks/useBookings";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import type { Slot } from "@calcom/features/schedules/lib/use-schedule/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -19,7 +19,7 @@ import { Button } from "@calcom/ui/components/button";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
|
||||
import { useCheckOverlapWithOverlay } from "@calcom/features/bookings/lib/useCheckOverlapWithOverlay";
|
||||
import type { Slots } from "@calcom/features/bookings/types";
|
||||
|
||||
@@ -18,9 +18,9 @@ import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
|
||||
import { formatEventFromTime } from "@calcom/features/bookings/Booker/utils/dates";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm";
|
||||
import type { IUseBookingErrors, IUseBookingLoadingStates } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
|
||||
import type { IUseBookingErrors, IUseBookingLoadingStates } from "../../hooks/useBookings";
|
||||
import { BookingFields } from "./BookingFields";
|
||||
import { FormSkeleton } from "./Skeleton";
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { DialogContent } from "@calcom/ui/components/dialog";
|
||||
import { getDurationFormatted } from "../event-meta/Duration";
|
||||
import { FromTime } from "@calcom/features/bookings/Booker/utils/dates";
|
||||
import { useEvent } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
|
||||
const BookEventFormWrapper = ({ children, onCancel }: { onCancel: () => void; children: ReactNode }) => {
|
||||
const { data } = useEvent();
|
||||
|
||||
@@ -35,7 +35,8 @@ import "@calcom/dayjs/__mocks__";
|
||||
import "@calcom/web/modules/auth/components/Turnstile";
|
||||
|
||||
import { render, screen } from "@calcom/features/bookings/Booker/__tests__/test-utils";
|
||||
import type { BookerProps, WrappedBookerProps } from "@calcom/features/bookings/Booker/types";
|
||||
import type { BookerProps } from "@calcom/features/bookings/Booker/types";
|
||||
import type { WrappedBookerProps } from "../types";
|
||||
import { Booker } from "./Booker";
|
||||
|
||||
vi.mock("framer-motion", async (importOriginal) => {
|
||||
|
||||
@@ -6,15 +6,16 @@ import { useEmbedUiConfig } from "@calcom/embed-core/embed-iframe";
|
||||
import { updateEmbedBookerState } from "@calcom/embed-core/src/embed-iframe";
|
||||
import TurnstileCaptcha from "@calcom/web/modules/auth/components/Turnstile";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { useIsQuickAvailabilityCheckFeatureEnabled } from "@calcom/features/bookings/Booker/components/hooks/useIsQuickAvailabilityCheckFeatureEnabled";
|
||||
import useSkipConfirmStep from "@calcom/features/bookings/Booker/components/hooks/useSkipConfirmStep";
|
||||
import { useIsQuickAvailabilityCheckFeatureEnabled } from "../hooks/useIsQuickAvailabilityCheckFeatureEnabled";
|
||||
import { useSkipConfirmStep } from "@calcom/web/modules/bookings/hooks/useSkipConfirmStep";
|
||||
import {
|
||||
fadeInLeft,
|
||||
getBookerSizeClassNames,
|
||||
useBookerResizeAnimation,
|
||||
} from "@calcom/features/bookings/Booker/config";
|
||||
import framerFeatures from "@calcom/features/bookings/Booker/framer-features";
|
||||
import type { BookerProps, WrappedBookerProps } from "@calcom/features/bookings/Booker/types";
|
||||
import type { BookerProps } from "@calcom/features/bookings/Booker/types";
|
||||
import type { WrappedBookerProps } from "../types";
|
||||
import { isBookingDryRun } from "@calcom/features/bookings/Booker/utils/isBookingDryRun";
|
||||
import { isTimeSlotAvailable } from "@calcom/features/bookings/Booker/utils/isTimeslotAvailable";
|
||||
import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
|
||||
|
||||
@@ -8,13 +8,13 @@ import {
|
||||
useBookerStoreContext,
|
||||
useInitializeBookerStoreContext,
|
||||
} from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { useBookerLayout } from "@calcom/features/bookings/Booker/components/hooks/useBookerLayout";
|
||||
import { useBookingForm } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm";
|
||||
import { useBookings } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
|
||||
import { useCalendars } from "@calcom/features/bookings/Booker/components/hooks/useCalendars";
|
||||
import { useSlots } from "@calcom/features/bookings/Booker/components/hooks/useSlots";
|
||||
import { useVerifyCode } from "@calcom/features/bookings/Booker/components/hooks/useVerifyCode";
|
||||
import { useVerifyEmail } from "@calcom/features/bookings/Booker/components/hooks/useVerifyEmail";
|
||||
import { useBookerLayout } from "@calcom/features/bookings/Booker/hooks/useBookerLayout";
|
||||
import { useBookingForm } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
|
||||
import { useBookings } from "../hooks/useBookings";
|
||||
import { useCalendars } from "../hooks/useCalendars";
|
||||
import { useSlots } from "../hooks/useSlots";
|
||||
import { useVerifyCode } from "../hooks/useVerifyCode";
|
||||
import { useVerifyEmail } from "../hooks/useVerifyEmail";
|
||||
import { useInitializeBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { useEvent, useScheduleForEvent } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import { useBrandColors } from "@calcom/features/bookings/Booker/utils/use-brand-colors";
|
||||
|
||||
@@ -10,7 +10,7 @@ import { weekdayToWeekIndex } from "@calcom/lib/dayjs";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
import type { PeriodData } from "@calcom/types/Event";
|
||||
import { useSlotsViewOnSmallScreen } from "@calcom/features/bookings/Booker/components/hooks/useSlotsViewOnSmallScreen";
|
||||
import { useSlotsViewOnSmallScreen } from "@calcom/embed-core/embed-iframe";
|
||||
|
||||
import type { Slots } from "@calcom/features/bookings/types";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Timezone as PlatformTimezoneSelect } from "@calcom/atoms/timezone";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
import { fadeInUp } from "@calcom/features/bookings/Booker/config";
|
||||
import type { Timezone } from "@calcom/features/bookings/Booker/types";
|
||||
import { FromToTime } from "@calcom/features/bookings/Booker/utils/dates";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { useInitializeWeekStart } from "@calcom/features/bookings/Booker/components/hooks/useInitializeWeekStart";
|
||||
import { useInitializeWeekStart } from "@calcom/web/modules/bookings/hooks/useInitializeWeekStart";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { formatDateTime } from "@calcom/lib/dateTimeFormatter";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
@@ -2,8 +2,8 @@ import { useMemo, useEffect } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/components/hooks/useAvailableTimeSlots";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/hooks/useAvailableTimeSlots";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
|
||||
import type { CalendarEvent } from "@calcom/features/calendars/weeklyview/types/events";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
|
||||
import { useOverlayCalendar } from "@calcom/features/bookings/Booker/components/hooks/useOverlayCalendar";
|
||||
import type { WrappedBookerPropsMain } from "@calcom/features/bookings/Booker/types";
|
||||
import { useOverlayCalendar } from "@calcom/web/modules/bookings/hooks/useOverlayCalendar";
|
||||
import type { WrappedBookerPropsMain } from "../../types";
|
||||
import { useEffect } from "react";
|
||||
import { OverlayCalendarContinueModal } from "./OverlayCalendarContinueModal";
|
||||
import { OverlayCalendarSettingsModal } from "./OverlayCalendarSettingsModal";
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Input } from "@calcom/ui/components/form";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
|
||||
export const EventOccurences = ({ event }: { event: Pick<BookerEvent, "recurringEvent"> }) => {
|
||||
const maxOccurences = event.recurringEvent?.count || null;
|
||||
|
||||
@@ -0,0 +1,583 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRef, useState, useEffect } from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import { createPaymentLink } from "@calcom/app-store/stripepayment/lib/client";
|
||||
import { useHandleBookEvent } from "@calcom/atoms/hooks/bookings/useHandleBookEvent";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { sdkActionManager } from "@calcom/embed-core/embed-iframe";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { updateQueryParam, getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
|
||||
import { storeDecoyBooking } from "@calcom/features/bookings/lib/client/decoyBookingStore";
|
||||
import { createBooking } from "@calcom/features/bookings/lib/create-booking";
|
||||
import { createInstantBooking } from "@calcom/features/bookings/lib/create-instant-booking";
|
||||
import { createRecurringBooking } from "@calcom/features/bookings/lib/create-recurring-booking";
|
||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { getFullName } from "@calcom/features/form-builder/utils";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { localStorage } from "@calcom/lib/webstorage";
|
||||
import { BookingStatus } from "@calcom/prisma/enums";
|
||||
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { useBookingSuccessRedirect } from "@calcom/features/bookings/lib/bookingSuccessRedirect";
|
||||
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
|
||||
|
||||
export interface IUseBookings {
|
||||
event: {
|
||||
data?:
|
||||
| (Pick<
|
||||
BookerEvent,
|
||||
| "id"
|
||||
| "slug"
|
||||
| "subsetOfHosts"
|
||||
| "requiresConfirmation"
|
||||
| "isDynamic"
|
||||
| "metadata"
|
||||
| "forwardParamsSuccessRedirect"
|
||||
| "successRedirectUrl"
|
||||
| "length"
|
||||
| "recurringEvent"
|
||||
| "schedulingType"
|
||||
> & {
|
||||
subsetOfUsers: Pick<
|
||||
BookerEvent["subsetOfUsers"][number],
|
||||
"name" | "username" | "avatarUrl" | "weekStart" | "profile" | "bookerUrl"
|
||||
>[];
|
||||
})
|
||||
| null;
|
||||
};
|
||||
hashedLink?: string | null;
|
||||
bookingForm: UseBookingFormReturnType["bookingForm"];
|
||||
metadata: Record<string, string>;
|
||||
teamMemberEmail?: string | null;
|
||||
isBookingDryRun?: boolean;
|
||||
}
|
||||
|
||||
const getBaseBookingEventPayload = (booking: {
|
||||
title?: string;
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
eventTypeId?: number | null;
|
||||
status?: BookingStatus;
|
||||
paymentRequired: boolean;
|
||||
isRecurring: boolean;
|
||||
videoCallUrl?: string;
|
||||
}) => {
|
||||
return {
|
||||
title: booking.title,
|
||||
startTime: booking.startTime,
|
||||
endTime: booking.endTime,
|
||||
eventTypeId: booking.eventTypeId,
|
||||
status: booking.status,
|
||||
paymentRequired: booking.paymentRequired,
|
||||
isRecurring: booking.isRecurring,
|
||||
videoCallUrl: booking.videoCallUrl,
|
||||
};
|
||||
};
|
||||
|
||||
const getBookingSuccessfulEventPayload = (booking: {
|
||||
title?: string;
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
eventTypeId?: number | null;
|
||||
status?: BookingStatus;
|
||||
paymentRequired: boolean;
|
||||
uid?: string;
|
||||
isRecurring: boolean;
|
||||
videoCallUrl?: string;
|
||||
}) => {
|
||||
return {
|
||||
uid: booking.uid,
|
||||
...getBaseBookingEventPayload(booking),
|
||||
};
|
||||
};
|
||||
|
||||
const getRescheduleBookingSuccessfulEventPayload = getBookingSuccessfulEventPayload;
|
||||
|
||||
export const getDryRunBookingSuccessfulEventPayload = getBaseBookingEventPayload;
|
||||
|
||||
export const getDryRunRescheduleBookingSuccessfulEventPayload = getDryRunBookingSuccessfulEventPayload;
|
||||
export interface IUseBookingLoadingStates {
|
||||
creatingBooking: boolean;
|
||||
creatingRecurringBooking: boolean;
|
||||
creatingInstantBooking: boolean;
|
||||
}
|
||||
|
||||
export interface IUseBookingErrors {
|
||||
hasDataErrors: boolean;
|
||||
dataErrors: unknown;
|
||||
}
|
||||
export type UseBookingsReturnType = ReturnType<typeof useBookings>;
|
||||
|
||||
const STORAGE_KEY = "instantBookingData";
|
||||
const COOLDOWN_STORAGE_KEY = "instantBookingCooldownByEvent";
|
||||
const COOLDOWN_WINDOW_MS = 10 * 60 * 1000; // 10 minutes
|
||||
|
||||
type InstantBookingCooldownMap = Record<string, number>;
|
||||
|
||||
const readInstantCooldownMap = (): InstantBookingCooldownMap => {
|
||||
try {
|
||||
const raw = localStorage.getItem(COOLDOWN_STORAGE_KEY);
|
||||
return raw ? (JSON.parse(raw) as InstantBookingCooldownMap) : {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
const writeInstantCooldownMap = (map: InstantBookingCooldownMap) => {
|
||||
try {
|
||||
localStorage.setItem(COOLDOWN_STORAGE_KEY, JSON.stringify(map));
|
||||
} catch {
|
||||
// don't do anything
|
||||
}
|
||||
};
|
||||
|
||||
const getInstantCooldownRemainingMs = (eventTypeId?: number | null): number => {
|
||||
if (!eventTypeId) return 0;
|
||||
const map = readInstantCooldownMap();
|
||||
const lastTs = map[String(eventTypeId)];
|
||||
if (!lastTs) return 0;
|
||||
const remaining = lastTs + COOLDOWN_WINDOW_MS - Date.now();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
};
|
||||
|
||||
const setInstantCooldownNow = (eventTypeId?: number | null) => {
|
||||
if (!eventTypeId) return;
|
||||
const map = readInstantCooldownMap();
|
||||
map[String(eventTypeId)] = Date.now();
|
||||
writeInstantCooldownMap(map);
|
||||
};
|
||||
|
||||
const storeInLocalStorage = ({
|
||||
eventTypeId,
|
||||
expiryTime,
|
||||
bookingId,
|
||||
}: {
|
||||
eventTypeId: number;
|
||||
expiryTime: Date;
|
||||
bookingId: number;
|
||||
}) => {
|
||||
const value = JSON.stringify({ eventTypeId, expiryTime, bookingId });
|
||||
localStorage.setItem(STORAGE_KEY, value);
|
||||
};
|
||||
|
||||
export const useBookings = ({ event, hashedLink, bookingForm, metadata, isBookingDryRun }: IUseBookings) => {
|
||||
const router = useRouter();
|
||||
const eventSlug = useBookerStoreContext((state) => state.eventSlug);
|
||||
const eventTypeId = useBookerStoreContext((state) => state.eventId);
|
||||
const isInstantMeeting = useBookerStoreContext((state) => state.isInstantMeeting);
|
||||
|
||||
const [rescheduleUid, setRescheduleUid] = useBookerStoreContext(
|
||||
(state) => [state.rescheduleUid, state.setRescheduleUid],
|
||||
shallow
|
||||
);
|
||||
const rescheduledBy = useBookerStoreContext((state) => state.rescheduledBy);
|
||||
const [bookingData, setBookingData] = useBookerStoreContext(
|
||||
(state) => [state.bookingData, state.setBookingData],
|
||||
shallow
|
||||
);
|
||||
const timeslot = useBookerStoreContext((state) => state.selectedTimeslot);
|
||||
const { t } = useLocale();
|
||||
const bookingSuccessRedirect = useBookingSuccessRedirect();
|
||||
const bookerFormErrorRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const [instantMeetingTokenExpiryTime, setExpiryTime] = useState<Date | undefined>();
|
||||
const [instantVideoMeetingUrl, setInstantVideoMeetingUrl] = useState<string | undefined>();
|
||||
const duration = useBookerStoreContext((state) => state.selectedDuration);
|
||||
|
||||
const isRescheduling = !!rescheduleUid && !!bookingData;
|
||||
|
||||
const bookingId = parseInt(getQueryParam("bookingId") ?? "0");
|
||||
|
||||
useEffect(() => {
|
||||
if (!isInstantMeeting) return;
|
||||
|
||||
const storedInfo = localStorage.getItem(STORAGE_KEY);
|
||||
|
||||
if (storedInfo) {
|
||||
const parsedInfo = JSON.parse(storedInfo);
|
||||
|
||||
const parsedInstantBookingInfo =
|
||||
parsedInfo.eventTypeId === eventTypeId &&
|
||||
isInstantMeeting &&
|
||||
new Date(parsedInfo.expiryTime) > new Date()
|
||||
? parsedInfo
|
||||
: null;
|
||||
|
||||
if (parsedInstantBookingInfo) {
|
||||
setExpiryTime(parsedInstantBookingInfo.expiryTime);
|
||||
updateQueryParam("bookingId", parsedInstantBookingInfo.bookingId);
|
||||
}
|
||||
}
|
||||
}, [eventTypeId, isInstantMeeting]);
|
||||
|
||||
const instantConnectCooldownMs = getInstantCooldownRemainingMs(eventTypeId);
|
||||
|
||||
const _instantBooking = trpc.viewer.bookings.getInstantBookingLocation.useQuery(
|
||||
{
|
||||
bookingId: bookingId,
|
||||
},
|
||||
{
|
||||
enabled: !!bookingId,
|
||||
refetchInterval: 2000,
|
||||
refetchIntervalInBackground: true,
|
||||
}
|
||||
);
|
||||
useEffect(
|
||||
function refactorMeWithoutEffect() {
|
||||
const data = _instantBooking.data;
|
||||
|
||||
if (!data || !data.booking) return;
|
||||
try {
|
||||
const locationVideoCallUrl: string | undefined = bookingMetadataSchema.parse(
|
||||
data.booking?.metadata || {}
|
||||
)?.videoCallUrl;
|
||||
|
||||
if (locationVideoCallUrl) {
|
||||
setInstantVideoMeetingUrl(locationVideoCallUrl);
|
||||
} else {
|
||||
showToast(t("something_went_wrong_on_our_end"), "error");
|
||||
}
|
||||
} catch {
|
||||
showToast(t("something_went_wrong_on_our_end"), "error");
|
||||
}
|
||||
},
|
||||
[_instantBooking.data]
|
||||
);
|
||||
|
||||
const createBookingMutation = useMutation({
|
||||
mutationFn: createBooking,
|
||||
onSuccess: (booking) => {
|
||||
if (booking.isDryRun) {
|
||||
if (isRescheduling) {
|
||||
sdkActionManager?.fire(
|
||||
"dryRunRescheduleBookingSuccessfulV2",
|
||||
getDryRunRescheduleBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: false,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
sdkActionManager?.fire(
|
||||
"dryRunBookingSuccessfulV2",
|
||||
getDryRunBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: false,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
router.push("/booking/dry-run-successful");
|
||||
return;
|
||||
}
|
||||
|
||||
if ("isShortCircuitedBooking" in booking && booking.isShortCircuitedBooking) {
|
||||
if (!booking.uid) {
|
||||
console.error("Decoy booking missing uid");
|
||||
return;
|
||||
}
|
||||
|
||||
const bookingData = {
|
||||
uid: booking.uid,
|
||||
title: booking.title ?? null,
|
||||
startTime: booking.startTime,
|
||||
endTime: booking.endTime,
|
||||
booker: booking.attendees?.[0] ?? null,
|
||||
host: booking.user ?? null,
|
||||
location: booking.location ?? null,
|
||||
};
|
||||
|
||||
storeDecoyBooking(bookingData);
|
||||
router.push(`/booking-successful/${booking.uid}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { uid, paymentUid } = booking;
|
||||
const fullName = getFullName(bookingForm.getValues("responses.name"));
|
||||
|
||||
const users = event.data?.subsetOfHosts?.length
|
||||
? event.data?.subsetOfHosts.map((host) => host.user)
|
||||
: event.data?.subsetOfUsers;
|
||||
|
||||
const validDuration = event.data?.isDynamic
|
||||
? duration || event.data?.length
|
||||
: duration && event.data?.metadata?.multipleDuration?.includes(duration)
|
||||
? duration
|
||||
: event.data?.length;
|
||||
|
||||
if (isRescheduling) {
|
||||
sdkActionManager?.fire("rescheduleBookingSuccessful", {
|
||||
booking: booking,
|
||||
eventType: event.data,
|
||||
date: booking?.startTime?.toString() || "",
|
||||
duration: validDuration,
|
||||
organizer: {
|
||||
name: users?.[0]?.name || "Nameless",
|
||||
email: booking?.userPrimaryEmail || booking.user?.email || "Email-less",
|
||||
timeZone: booking.user?.timeZone || "Europe/London",
|
||||
},
|
||||
confirmed: !(booking.status === BookingStatus.PENDING && event.data?.requiresConfirmation),
|
||||
});
|
||||
sdkActionManager?.fire(
|
||||
"rescheduleBookingSuccessfulV2",
|
||||
getRescheduleBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: false,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
sdkActionManager?.fire("bookingSuccessful", {
|
||||
booking: booking,
|
||||
eventType: event.data,
|
||||
date: booking?.startTime?.toString() || "",
|
||||
duration: validDuration,
|
||||
organizer: {
|
||||
name: users?.[0]?.name || "Nameless",
|
||||
email: booking?.userPrimaryEmail || booking.user?.email || "Email-less",
|
||||
timeZone: booking.user?.timeZone || "Europe/London",
|
||||
},
|
||||
confirmed: !(booking.status === BookingStatus.PENDING && event.data?.requiresConfirmation),
|
||||
});
|
||||
|
||||
sdkActionManager?.fire(
|
||||
"bookingSuccessfulV2",
|
||||
getBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: false,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (paymentUid) {
|
||||
router.push(
|
||||
createPaymentLink({
|
||||
paymentUid,
|
||||
date: timeslot,
|
||||
name: fullName,
|
||||
email: bookingForm.getValues("responses.email"),
|
||||
absolute: false,
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uid) {
|
||||
console.error("No uid returned from createBookingMutation");
|
||||
return;
|
||||
}
|
||||
|
||||
const query = {
|
||||
isSuccessBookingPage: true,
|
||||
email: bookingForm.getValues("responses.email"),
|
||||
eventTypeSlug: eventSlug,
|
||||
seatReferenceUid: "seatReferenceUid" in booking ? (booking.seatReferenceUid as string) : null,
|
||||
formerTime:
|
||||
isRescheduling && bookingData?.startTime ? dayjs(bookingData.startTime).toString() : undefined,
|
||||
rescheduledBy, // ensure further reschedules performed on the success page are recorded correctly
|
||||
};
|
||||
|
||||
bookingSuccessRedirect({
|
||||
successRedirectUrl: event?.data?.successRedirectUrl || "",
|
||||
query,
|
||||
booking: booking,
|
||||
forwardParamsSuccessRedirect:
|
||||
event?.data?.forwardParamsSuccessRedirect === undefined
|
||||
? true
|
||||
: event?.data?.forwardParamsSuccessRedirect,
|
||||
});
|
||||
},
|
||||
onError: (err) => {
|
||||
if (bookerFormErrorRef?.current) {
|
||||
bookerFormErrorRef.current.scrollIntoView({ behavior: "smooth" });
|
||||
}
|
||||
|
||||
const error = err as Error & {
|
||||
data: { rescheduleUid: string; startTime: string; attendees: string[]; seatUid?: string };
|
||||
traceId?: string;
|
||||
};
|
||||
|
||||
if (error.message === ErrorCode.BookerLimitExceededReschedule && error.data?.rescheduleUid) {
|
||||
setRescheduleUid(error.data?.seatUid ?? error.data?.rescheduleUid);
|
||||
setBookingData({
|
||||
uid: error.data?.rescheduleUid,
|
||||
startTime: error.data?.startTime,
|
||||
attendees: error.data?.attendees,
|
||||
} as unknown as GetBookingType);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const createInstantBookingMutation = useMutation({
|
||||
mutationFn: createInstantBooking,
|
||||
onSuccess: (responseData) => {
|
||||
if (eventTypeId) {
|
||||
storeInLocalStorage({
|
||||
eventTypeId,
|
||||
expiryTime: responseData.expires,
|
||||
bookingId: responseData.bookingId,
|
||||
});
|
||||
setInstantCooldownNow(eventTypeId);
|
||||
}
|
||||
|
||||
updateQueryParam("bookingId", responseData.bookingId);
|
||||
setExpiryTime(responseData.expires);
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error("Error creating instant booking", err);
|
||||
if (bookerFormErrorRef?.current) {
|
||||
bookerFormErrorRef.current.scrollIntoView({ behavior: "smooth" });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const createRecurringBookingMutation = useMutation({
|
||||
mutationFn: createRecurringBooking,
|
||||
onSuccess: async (bookings) => {
|
||||
const booking = bookings[0] || {};
|
||||
|
||||
if (booking.isDryRun) {
|
||||
if (isRescheduling) {
|
||||
sdkActionManager?.fire("dryRunRescheduleBookingSuccessfulV2", {
|
||||
...getDryRunRescheduleBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: true,
|
||||
}),
|
||||
allBookings: bookings.map((booking) => ({
|
||||
startTime: booking.startTime,
|
||||
endTime: booking.endTime,
|
||||
})),
|
||||
});
|
||||
} else {
|
||||
sdkActionManager?.fire("dryRunBookingSuccessfulV2", {
|
||||
...getDryRunBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: true,
|
||||
}),
|
||||
allBookings: bookings.map((booking) => ({
|
||||
startTime: booking.startTime,
|
||||
endTime: booking.endTime,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
router.push("/booking/dry-run-successful");
|
||||
return;
|
||||
}
|
||||
|
||||
const { uid } = booking;
|
||||
|
||||
if (!uid) {
|
||||
console.error("No uid returned from createRecurringBookingMutation");
|
||||
return;
|
||||
}
|
||||
|
||||
const query = {
|
||||
isSuccessBookingPage: true,
|
||||
allRemainingBookings: true,
|
||||
email: bookingForm.getValues("responses.email"),
|
||||
eventTypeSlug: eventSlug,
|
||||
formerTime:
|
||||
isRescheduling && bookingData?.startTime ? dayjs(bookingData.startTime).toString() : undefined,
|
||||
};
|
||||
|
||||
if (isRescheduling) {
|
||||
// NOTE: It is recommended to define the event payload in the argument itself to provide a better type safety.
|
||||
sdkActionManager?.fire("rescheduleBookingSuccessfulV2", {
|
||||
...getRescheduleBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: true,
|
||||
}),
|
||||
allBookings: bookings.map((booking) => ({
|
||||
startTime: booking.startTime,
|
||||
endTime: booking.endTime,
|
||||
})),
|
||||
});
|
||||
} else {
|
||||
sdkActionManager?.fire("bookingSuccessfulV2", {
|
||||
...getBookingSuccessfulEventPayload({
|
||||
...booking,
|
||||
isRecurring: true,
|
||||
}),
|
||||
allBookings: bookings.map((booking) => ({
|
||||
startTime: booking.startTime,
|
||||
endTime: booking.endTime,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
bookingSuccessRedirect({
|
||||
successRedirectUrl: event?.data?.successRedirectUrl || "",
|
||||
query,
|
||||
booking,
|
||||
forwardParamsSuccessRedirect:
|
||||
event?.data?.forwardParamsSuccessRedirect === undefined
|
||||
? true
|
||||
: event?.data?.forwardParamsSuccessRedirect,
|
||||
});
|
||||
},
|
||||
onError: (err, _, ctx) => {
|
||||
console.error("Error creating recurring booking", err);
|
||||
// eslint-disable-next-line @calcom/eslint/no-scroll-into-view-embed -- It is only called when user takes an action in embed
|
||||
bookerFormErrorRef && bookerFormErrorRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
},
|
||||
});
|
||||
|
||||
const handleBookEvent = useHandleBookEvent({
|
||||
event,
|
||||
bookingForm,
|
||||
hashedLink,
|
||||
metadata,
|
||||
handleInstantBooking: (variables: Parameters<typeof createInstantBookingMutation.mutate>[0]) => {
|
||||
const remaining = getInstantCooldownRemainingMs(eventTypeId);
|
||||
if (remaining > 0) {
|
||||
showToast(
|
||||
t("please_try_again_later_or_book_another_slot", { remaining: Math.ceil(remaining / 60000) }),
|
||||
"error"
|
||||
);
|
||||
return;
|
||||
}
|
||||
createInstantBookingMutation.mutate(variables);
|
||||
},
|
||||
handleRecBooking: createRecurringBookingMutation.mutate,
|
||||
handleBooking: createBookingMutation.mutate,
|
||||
isBookingDryRun,
|
||||
});
|
||||
|
||||
const errors = {
|
||||
hasDataErrors: Boolean(
|
||||
createBookingMutation.isError ||
|
||||
createRecurringBookingMutation.isError ||
|
||||
createInstantBookingMutation.isError
|
||||
),
|
||||
dataErrors:
|
||||
createBookingMutation.error ||
|
||||
createRecurringBookingMutation.error ||
|
||||
createInstantBookingMutation.error,
|
||||
};
|
||||
|
||||
// A redirect is triggered on mutation success, so keep the loading state while it is happening.
|
||||
const loadingStates = {
|
||||
creatingBooking: createBookingMutation.isPending || createBookingMutation.isSuccess,
|
||||
creatingRecurringBooking:
|
||||
createRecurringBookingMutation.isPending || createRecurringBookingMutation.isSuccess,
|
||||
creatingInstantBooking: createInstantBookingMutation.isPending,
|
||||
};
|
||||
|
||||
return {
|
||||
handleBookEvent,
|
||||
expiryTime: instantMeetingTokenExpiryTime,
|
||||
bookingForm,
|
||||
bookerFormErrorRef,
|
||||
errors,
|
||||
loadingStates,
|
||||
instantVideoMeetingUrl,
|
||||
instantConnectCooldownMs,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import { useOverlayCalendarStore } from "@calcom/features/bookings/Booker/components/OverlayCalendar/store";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { ToggledConnectedCalendars } from "@calcom/features/bookings/Booker/types";
|
||||
import { useTimePreferences } from "@calcom/features/bookings/lib";
|
||||
import { localStorage } from "@calcom/lib/webstorage";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
type UseCalendarsProps = {
|
||||
hasSession: boolean;
|
||||
};
|
||||
|
||||
export const useCalendars = ({ hasSession }: UseCalendarsProps) => {
|
||||
const searchParams = useSearchParams();
|
||||
const selectedDate = useBookerStore((state) => state.selectedDate);
|
||||
const { timezone } = useTimePreferences();
|
||||
const switchEnabled =
|
||||
searchParams?.get("overlayCalendar") === "true" ||
|
||||
localStorage?.getItem("overlayCalendarSwitchDefault") === "true";
|
||||
|
||||
const [set, setSet] = useState<Set<ToggledConnectedCalendars>>(() => {
|
||||
const storedValue = localStorage.getItem("toggledConnectedCalendars");
|
||||
return storedValue ? new Set(JSON.parse(storedValue)) : new Set([]);
|
||||
});
|
||||
|
||||
const [calendarSettingsOverlay] = useOverlayCalendarStore(
|
||||
(state) => [state.calendarSettingsOverlayModal, state.setCalendarSettingsOverlayModal],
|
||||
shallow
|
||||
);
|
||||
|
||||
const { data: overlayBusyDates, isError } = trpc.viewer.availability.calendarOverlay.useQuery(
|
||||
{
|
||||
loggedInUsersTz: timezone || "Europe/London",
|
||||
dateFrom: selectedDate,
|
||||
dateTo: selectedDate,
|
||||
calendarsToLoad: Array.from(set).map((item) => ({
|
||||
credentialId: item.credentialId,
|
||||
externalId: item.externalId,
|
||||
})),
|
||||
},
|
||||
{
|
||||
enabled: hasSession && set.size > 0 && switchEnabled,
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(
|
||||
function refactorMeWithoutEffect() {
|
||||
if (!isError) return;
|
||||
setSet(new Set([]));
|
||||
},
|
||||
[isError]
|
||||
);
|
||||
|
||||
const { data, isPending } = trpc.viewer.calendars.connectedCalendars.useQuery(
|
||||
{
|
||||
skipSync: true,
|
||||
},
|
||||
{
|
||||
enabled: !!calendarSettingsOverlay || Boolean(searchParams?.get("overlayCalendar")),
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
overlayBusyDates,
|
||||
isOverlayCalendarEnabled: switchEnabled,
|
||||
connectedCalendars: data?.connectedCalendars || [],
|
||||
loadingConnectedCalendar: isPending,
|
||||
onToggleCalendar: setSet,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { getDecoyBooking } from "@calcom/features/bookings/lib/client/decoyBookingStore";
|
||||
import type { DecoyBookingData } from "@calcom/features/bookings/lib/client/decoyBookingStore";
|
||||
|
||||
/**
|
||||
* Hook to retrieve and manage decoy booking data from localStorage
|
||||
* @param uid - The booking uid
|
||||
* @returns The booking data or null if not found/expired
|
||||
*/
|
||||
export function useDecoyBooking(uid: string) {
|
||||
const router = useRouter();
|
||||
const [bookingData, setBookingData] = useState<DecoyBookingData | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const data = getDecoyBooking(uid);
|
||||
|
||||
if (!data) {
|
||||
router.push("/404");
|
||||
return;
|
||||
}
|
||||
|
||||
setBookingData(data);
|
||||
}, [uid, router]);
|
||||
|
||||
return bookingData;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useSlotsViewOnSmallScreen } from "@calcom/embed-core/embed-iframe";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
|
||||
export const useInitializeWeekStart = (isPlatform: boolean, isCalendarView: boolean) => {
|
||||
const slotsViewOnSmallScreen = useSlotsViewOnSmallScreen();
|
||||
const today = dayjs();
|
||||
const weekStart = today.startOf("week").format("YYYY-MM-DD");
|
||||
const setSelectedDate = useBookerStoreContext((state) => state.setSelectedDate);
|
||||
|
||||
useEffect(() => {
|
||||
// don't auto-select date if slots view on small screen is enabled
|
||||
// auto-selecting would open the slots modal in that case which the user would most probably have to close
|
||||
if (slotsViewOnSmallScreen) return;
|
||||
|
||||
if (isPlatform && isCalendarView) {
|
||||
setSelectedDate({ date: weekStart, omitUpdatingParams: true });
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
import { isVisitorWithinPercentage } from "@calcom/features/bookings/Booker/utils/isFeatureEnabledForVisitor";
|
||||
import { PUBLIC_QUICK_AVAILABILITY_ROLLOUT } from "@calcom/lib/constants";
|
||||
|
||||
export const useIsQuickAvailabilityCheckFeatureEnabled = () => {
|
||||
const isQuickAvailabilityCheckFeatureEnabledRef = useRef(
|
||||
isVisitorWithinPercentage({ percentage: PUBLIC_QUICK_AVAILABILITY_ROLLOUT })
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("QuickAvailabilityCheck feature enabled:", isQuickAvailabilityCheckFeatureEnabledRef.current);
|
||||
}, []);
|
||||
|
||||
return isQuickAvailabilityCheckFeatureEnabledRef.current;
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useOverlayCalendarStore } from "@calcom/features/bookings/Booker/components/OverlayCalendar/store";
|
||||
import type { ToggledConnectedCalendars } from "@calcom/features/bookings/Booker/types";
|
||||
import { useTimePreferences } from "@calcom/features/bookings/lib";
|
||||
|
||||
import type { WrappedBookerPropsMain } from "../types";
|
||||
import { useLocalSet } from "@calcom/features/bookings/Booker/hooks/useLocalSet";
|
||||
|
||||
export const useOverlayCalendar = ({
|
||||
connectedCalendars,
|
||||
overlayBusyDates,
|
||||
onToggleCalendar,
|
||||
}: Pick<
|
||||
WrappedBookerPropsMain["calendars"],
|
||||
"overlayBusyDates" | "onToggleCalendar" | "connectedCalendars"
|
||||
>): {
|
||||
isOpenOverlayContinueModal: boolean;
|
||||
isOpenOverlaySettingsModal: boolean;
|
||||
handleCloseContinueModal: (val: boolean) => void;
|
||||
handleCloseSettingsModal: (val: boolean) => void;
|
||||
handleToggleConnectedCalendar: (externalCalendarId: string, credentialId: number) => void;
|
||||
checkIsCalendarToggled: (externalId: string, credentialId: number) => boolean;
|
||||
} => {
|
||||
const { set, toggleValue, hasItem } = useLocalSet<ToggledConnectedCalendars>(
|
||||
"toggledConnectedCalendars",
|
||||
[]
|
||||
);
|
||||
const [initalised, setInitalised] = useState(false);
|
||||
const [continueWithProvider, setContinueWithProvider] = useOverlayCalendarStore(
|
||||
(state) => [state.continueWithProviderModal, state.setContinueWithProviderModal],
|
||||
shallow
|
||||
);
|
||||
const [calendarSettingsOverlay, setCalendarSettingsOverlay] = useOverlayCalendarStore(
|
||||
(state) => [state.calendarSettingsOverlayModal, state.setCalendarSettingsOverlayModal],
|
||||
shallow
|
||||
);
|
||||
const setOverlayBusyDates = useOverlayCalendarStore((state) => state.setOverlayBusyDates);
|
||||
const { timezone } = useTimePreferences();
|
||||
|
||||
useEffect(() => {
|
||||
if (overlayBusyDates) {
|
||||
const nowDate = dayjs();
|
||||
const usersTimezoneDate = nowDate.tz(timezone);
|
||||
|
||||
const offset = (usersTimezoneDate.utcOffset() - nowDate.utcOffset()) / 60;
|
||||
|
||||
const offsettedArray = overlayBusyDates.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
start: dayjs(item.start).add(offset, "hours").toDate(),
|
||||
end: dayjs(item.end).add(offset, "hours").toDate(),
|
||||
};
|
||||
});
|
||||
setOverlayBusyDates(offsettedArray);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [overlayBusyDates]);
|
||||
|
||||
useEffect(() => {
|
||||
if (connectedCalendars && set.size === 0 && !initalised) {
|
||||
connectedCalendars.forEach((item) => {
|
||||
item.calendars?.forEach((cal) => {
|
||||
const id = { credentialId: item.credentialId, externalId: cal.externalId };
|
||||
if (cal.primary) {
|
||||
toggleValue(id);
|
||||
}
|
||||
});
|
||||
});
|
||||
setInitalised(true);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [hasItem, set, initalised]);
|
||||
|
||||
const handleToggleConnectedCalendar = (externalCalendarId: string, credentialId: number): void => {
|
||||
const calendarsToLoad = toggleValue({
|
||||
credentialId: credentialId,
|
||||
externalId: externalCalendarId,
|
||||
});
|
||||
setOverlayBusyDates([]);
|
||||
onToggleCalendar(calendarsToLoad);
|
||||
};
|
||||
|
||||
return {
|
||||
isOpenOverlayContinueModal: continueWithProvider,
|
||||
isOpenOverlaySettingsModal: calendarSettingsOverlay,
|
||||
handleCloseContinueModal: (val: boolean) => setContinueWithProvider(val),
|
||||
handleCloseSettingsModal: (val: boolean) => setCalendarSettingsOverlay(val),
|
||||
handleToggleConnectedCalendar,
|
||||
checkIsCalendarToggled: (externalId: string, credentialId: number) => {
|
||||
return hasItem({
|
||||
credentialId: credentialId,
|
||||
externalId: externalId,
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { BookerState } from "@calcom/features/bookings/Booker/types";
|
||||
import { getBookingResponsesSchemaWithOptionalChecks } from "@calcom/features/bookings/lib/getBookingResponsesSchema";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
|
||||
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
|
||||
|
||||
export const useSkipConfirmStep = (
|
||||
bookingForm: UseBookingFormReturnType["bookingForm"],
|
||||
bookerState: BookerState,
|
||||
isInstantMeeting: boolean,
|
||||
isWeekView: boolean,
|
||||
bookingFields?: BookerEvent["bookingFields"],
|
||||
locations?: BookerEvent["locations"]
|
||||
) => {
|
||||
const bookingFormValues = bookingForm.getValues();
|
||||
|
||||
const [canSkip, setCanSkip] = useState(false);
|
||||
const rescheduleUid = useBookerStore((state) => state.rescheduleUid);
|
||||
|
||||
useEffect(() => {
|
||||
const checkSkipStep = async () => {
|
||||
if (!bookingFields || (locations && locations.length > 1)) {
|
||||
setCanSkip(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const responseSchema = getBookingResponsesSchemaWithOptionalChecks({
|
||||
bookingFields,
|
||||
view: rescheduleUid ? "reschedule" : "booking",
|
||||
});
|
||||
const responseSafeParse = await responseSchema.safeParseAsync(bookingFormValues.responses);
|
||||
|
||||
setCanSkip(responseSafeParse.success);
|
||||
} catch (error) {
|
||||
setCanSkip(false);
|
||||
}
|
||||
};
|
||||
const isSkipConfirmStepSupported = !isInstantMeeting && !isWeekView;
|
||||
if (bookerState === "selecting_time" && isSkipConfirmStepSupported) {
|
||||
checkSkipStep();
|
||||
}
|
||||
}, [bookingFormValues, bookingFields, rescheduleUid, bookerState, isWeekView, isInstantMeeting]);
|
||||
|
||||
return canSkip;
|
||||
};
|
||||
@@ -0,0 +1,166 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { useSlotReservationId } from "@calcom/features/bookings/Booker/useSlotReservationId";
|
||||
import { isBookingDryRun } from "@calcom/features/bookings/Booker/utils/isBookingDryRun";
|
||||
import {
|
||||
MINUTES_TO_BOOK,
|
||||
PUBLIC_QUERY_RESERVATION_INTERVAL_SECONDS,
|
||||
PUBLIC_QUERY_RESERVATION_STALE_TIME_SECONDS,
|
||||
} from "@calcom/lib/constants";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { QuickAvailabilityCheck } from "@calcom/features/bookings/Booker/types";
|
||||
import { useIsQuickAvailabilityCheckFeatureEnabled } from "./useIsQuickAvailabilityCheckFeatureEnabled";
|
||||
|
||||
const useQuickAvailabilityChecks = ({
|
||||
eventTypeId,
|
||||
eventDuration,
|
||||
timeslotsAsISOString,
|
||||
slotReservationId,
|
||||
}: {
|
||||
eventTypeId: number | undefined;
|
||||
eventDuration: number;
|
||||
timeslotsAsISOString: string[];
|
||||
slotReservationId: string | undefined | null;
|
||||
}) => {
|
||||
// Maintain a cache to ensure previous state is maintained as the request is fetched
|
||||
// It is important because tentatively selecting a new timeslot will cause a new request which is uncached.
|
||||
const cachedQuickAvailabilityChecksRef = useRef<QuickAvailabilityCheck[]>([]);
|
||||
const isQuickAvailabilityCheckFeatureEnabled = useIsQuickAvailabilityCheckFeatureEnabled();
|
||||
|
||||
if (!isQuickAvailabilityCheckFeatureEnabled) {
|
||||
return cachedQuickAvailabilityChecksRef.current;
|
||||
}
|
||||
|
||||
// Create array of slots with their UTC start and end dates
|
||||
const slotsToCheck = timeslotsAsISOString.map((slot) => {
|
||||
const slotDayjs = dayjs(slot);
|
||||
return {
|
||||
utcStartIso: slotDayjs.utc().toISOString(),
|
||||
utcEndIso: slotDayjs.add(eventDuration, "minutes").utc().toISOString(),
|
||||
};
|
||||
});
|
||||
|
||||
const isAvailableQuery = trpc.viewer.slots.isAvailable.useQuery(
|
||||
{
|
||||
slots: slotsToCheck,
|
||||
// enabled flag can't be true if eventTypeId is nullish
|
||||
|
||||
eventTypeId: eventTypeId!,
|
||||
},
|
||||
{
|
||||
refetchInterval: PUBLIC_QUERY_RESERVATION_INTERVAL_SECONDS * 1000,
|
||||
refetchOnWindowFocus: true,
|
||||
// We must have slotReservationId because it is possible that slotReservationId is set right after isAvailable request is made and we accidentally could consider the slot as unavailable.
|
||||
// isAvailable request also prevents querying reserved slots if uid is not set. We are safe from both sides.
|
||||
// TODO: We should move to creating uuid client side for reservation and not waiting for server to set uid cookie.
|
||||
enabled: !!(eventTypeId && timeslotsAsISOString.length > 0 && slotReservationId),
|
||||
staleTime: PUBLIC_QUERY_RESERVATION_STALE_TIME_SECONDS * 1000,
|
||||
}
|
||||
);
|
||||
|
||||
const quickAvailabilityChecks = isAvailableQuery.data?.slots;
|
||||
|
||||
// Only valid slots response should override the cache. In worst case, we let the actual booking flow(book/event call) decide whether to go ahead with the booking or not.
|
||||
if (quickAvailabilityChecks && quickAvailabilityChecks.length > 0) {
|
||||
cachedQuickAvailabilityChecksRef.current = quickAvailabilityChecks;
|
||||
}
|
||||
|
||||
return quickAvailabilityChecks || cachedQuickAvailabilityChecksRef.current;
|
||||
};
|
||||
|
||||
export type UseSlotsReturnType = ReturnType<typeof useSlots>;
|
||||
|
||||
export const useSlots = (event: { id: number; length: number } | null) => {
|
||||
const selectedDuration = useBookerStoreContext((state) => state.selectedDuration);
|
||||
const searchParams = useCompatSearchParams();
|
||||
const [selectedTimeslot, setSelectedTimeslot, tentativeSelectedTimeslots, setTentativeSelectedTimeslots] =
|
||||
useBookerStoreContext(
|
||||
(state) => [
|
||||
state.selectedTimeslot,
|
||||
state.setSelectedTimeslot,
|
||||
state.tentativeSelectedTimeslots,
|
||||
state.setTentativeSelectedTimeslots,
|
||||
],
|
||||
shallow
|
||||
);
|
||||
const [slotReservationId, setSlotReservationId] = useSlotReservationId();
|
||||
const reserveSlotMutation = trpc.viewer.slots.reserveSlot.useMutation({
|
||||
trpc: {
|
||||
context: {
|
||||
skipBatch: true,
|
||||
},
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
setSlotReservationId(data.uid);
|
||||
},
|
||||
});
|
||||
const removeSelectedSlot = trpc.viewer.slots.removeSelectedSlotMark.useMutation({
|
||||
trpc: { context: { skipBatch: true } },
|
||||
});
|
||||
|
||||
const handleRemoveSlot = () => {
|
||||
if (event?.id && slotReservationId) {
|
||||
removeSelectedSlot.mutate({ uid: slotReservationId });
|
||||
}
|
||||
};
|
||||
|
||||
const eventTypeId = event?.id;
|
||||
const eventDuration = selectedDuration || event?.length || 0;
|
||||
const allSelectedTimeslots = [...tentativeSelectedTimeslots, selectedTimeslot].filter(
|
||||
(slot): slot is string => slot !== null
|
||||
);
|
||||
|
||||
const allUniqueSelectedTimeslots = Array.from(new Set(allSelectedTimeslots));
|
||||
|
||||
const quickAvailabilityChecks = useQuickAvailabilityChecks({
|
||||
eventTypeId,
|
||||
eventDuration,
|
||||
timeslotsAsISOString: allUniqueSelectedTimeslots,
|
||||
slotReservationId,
|
||||
});
|
||||
|
||||
// In case of skipConfirm flow selectedTimeslot would never be set and instead we could have multiple tentatively selected timeslots, so we pick the latest one from it.
|
||||
const timeSlotToBeBooked = selectedTimeslot ?? allSelectedTimeslots.at(-1);
|
||||
|
||||
const handleReserveSlot = () => {
|
||||
if (eventTypeId && timeSlotToBeBooked && eventDuration) {
|
||||
reserveSlotMutation.mutate({
|
||||
slotUtcStartDate: dayjs(timeSlotToBeBooked).utc().toISOString(),
|
||||
eventTypeId,
|
||||
slotUtcEndDate: dayjs(timeSlotToBeBooked).utc().add(eventDuration, "minutes").toISOString(),
|
||||
_isDryRun: isBookingDryRun(searchParams),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
handleReserveSlot();
|
||||
|
||||
const interval = setInterval(() => {
|
||||
handleReserveSlot();
|
||||
}, parseInt(MINUTES_TO_BOOK) * 60 * 1000 - 2000);
|
||||
|
||||
return () => {
|
||||
handleRemoveSlot();
|
||||
clearInterval(interval);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [event?.id, timeSlotToBeBooked]);
|
||||
|
||||
return {
|
||||
setSelectedTimeslot,
|
||||
setTentativeSelectedTimeslots,
|
||||
selectedTimeslot,
|
||||
tentativeSelectedTimeslots,
|
||||
slotReservationId,
|
||||
allSelectedTimeslots,
|
||||
/**
|
||||
* Faster but not that accurate as getSchedule, but doesn't give false positive, so it is usable
|
||||
*/
|
||||
quickAvailabilityChecks,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
export type UseVerifyCodeReturnType = ReturnType<typeof useVerifyCode>;
|
||||
|
||||
type UseVerifyCodeProps = {
|
||||
onSuccess: (isVerified: boolean) => void;
|
||||
};
|
||||
|
||||
export const useVerifyCode = ({ onSuccess }: UseVerifyCodeProps) => {
|
||||
const { t } = useLocale();
|
||||
|
||||
const [isPending, setIsPending] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const [value, setValue] = useState("");
|
||||
const [hasVerified, setHasVerified] = useState(false);
|
||||
|
||||
const verifyCodeMutationUserSessionRequired = trpc.viewer.organizations.verifyCode.useMutation({
|
||||
onSuccess: (data) => {
|
||||
setIsPending(false);
|
||||
onSuccess(data);
|
||||
},
|
||||
onError: (err) => {
|
||||
setIsPending(false);
|
||||
setHasVerified(false);
|
||||
if (err.message === "invalid_code") {
|
||||
setError(t("code_provided_invalid"));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const verifyCodeMutationUserSessionNotRequired = trpc.viewer.auth.verifyCodeUnAuthenticated.useMutation({
|
||||
onSuccess: (data) => {
|
||||
setIsPending(false);
|
||||
onSuccess(data);
|
||||
},
|
||||
onError: (err) => {
|
||||
setIsPending(false);
|
||||
setHasVerified(false);
|
||||
if (err.message === "invalid_code") {
|
||||
setError(t("code_provided_invalid"));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const verifyCodeWithSessionRequired = (code: string, email: string) => {
|
||||
verifyCodeMutationUserSessionRequired.mutate({
|
||||
code,
|
||||
email,
|
||||
});
|
||||
};
|
||||
|
||||
const verifyCodeWithSessionNotRequired = (code: string, email: string) => {
|
||||
verifyCodeMutationUserSessionNotRequired.mutate({
|
||||
code,
|
||||
email,
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
verifyCodeWithSessionRequired,
|
||||
verifyCodeWithSessionNotRequired,
|
||||
isPending,
|
||||
setIsPending,
|
||||
error,
|
||||
value,
|
||||
hasVerified,
|
||||
setValue,
|
||||
setHasVerified,
|
||||
resetErrors: () => setError(""),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import { useDebounce } from "@calcom/lib/hooks/useDebounce";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
export interface IUseVerifyEmailProps {
|
||||
email: string;
|
||||
onVerifyEmail?: () => void;
|
||||
name?: string | { firstName: string; lastname?: string };
|
||||
requiresBookerEmailVerification?: boolean;
|
||||
}
|
||||
export type UseVerifyEmailReturnType = ReturnType<typeof useVerifyEmail>;
|
||||
export const useVerifyEmail = ({
|
||||
email,
|
||||
name,
|
||||
requiresBookerEmailVerification,
|
||||
onVerifyEmail,
|
||||
}: IUseVerifyEmailProps) => {
|
||||
const [isEmailVerificationModalVisible, setEmailVerificationModalVisible] = useState(false);
|
||||
const verifiedEmail = useBookerStore((state) => state.verifiedEmail);
|
||||
const setVerifiedEmail = useBookerStore((state) => state.setVerifiedEmail);
|
||||
const isRescheduling = useBookerStore((state) => Boolean(state.rescheduleUid && state.bookingData));
|
||||
const debouncedEmail = useDebounce(email, 600);
|
||||
const { data: session } = useSession();
|
||||
|
||||
const { t, i18n } = useLocale();
|
||||
const sendEmailVerificationByCodeMutation = trpc.viewer.auth.sendVerifyEmailCode.useMutation({
|
||||
onSuccess: () => {
|
||||
setEmailVerificationModalVisible(true);
|
||||
showToast(t("email_sent"), "success");
|
||||
},
|
||||
onError: () => {
|
||||
showToast(t("email_not_sent"), "error");
|
||||
},
|
||||
});
|
||||
|
||||
const { data: isEmailVerificationRequired } =
|
||||
trpc.viewer.public.checkIfUserEmailVerificationRequired.useQuery(
|
||||
{
|
||||
userSessionEmail: session?.user.email || "",
|
||||
email: debouncedEmail,
|
||||
},
|
||||
{
|
||||
enabled: !!debouncedEmail && !isRescheduling,
|
||||
}
|
||||
);
|
||||
|
||||
const handleVerifyEmail = () => {
|
||||
onVerifyEmail?.();
|
||||
|
||||
sendEmailVerificationByCodeMutation.mutate({
|
||||
email,
|
||||
username: typeof name === "string" ? name : name?.firstName,
|
||||
language: i18n.language || "en",
|
||||
});
|
||||
};
|
||||
|
||||
const isVerificationCodeSending = sendEmailVerificationByCodeMutation.isPending;
|
||||
|
||||
const renderConfirmNotVerifyEmailButtonCond =
|
||||
isRescheduling ||
|
||||
(!requiresBookerEmailVerification && !isEmailVerificationRequired) ||
|
||||
(email && verifiedEmail && verifiedEmail === email);
|
||||
|
||||
return {
|
||||
handleVerifyEmail,
|
||||
isEmailVerificationModalVisible,
|
||||
setEmailVerificationModalVisible,
|
||||
setVerifiedEmail,
|
||||
renderConfirmNotVerifyEmailButtonCond: Boolean(renderConfirmNotVerifyEmailButtonCond),
|
||||
isVerificationCodeSending,
|
||||
};
|
||||
};
|
||||
@@ -1,7 +1,17 @@
|
||||
import type { DataTableRow } from "@calcom/features/data-table/lib/separator";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import type { BookerEventQuery } from "@calcom/features/bookings/types";
|
||||
import type { useScheduleForEventReturnType } from "@calcom/features/bookings/Booker/utils/event";
|
||||
import type { ToggledConnectedCalendars, CustomClassNames } from "@calcom/features/bookings/Booker/types";
|
||||
import type { EventBusyDate } from "@calcom/types/Calendar";
|
||||
|
||||
import type { validStatuses } from "./lib/validStatuses";
|
||||
import type { UseBookerLayoutType } from "@calcom/features/bookings/Booker/hooks/useBookerLayout";
|
||||
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
|
||||
import type { UseBookingsReturnType } from "./hooks/useBookings";
|
||||
import type { UseSlotsReturnType } from "./hooks/useSlots";
|
||||
import type { UseVerifyCodeReturnType } from "./hooks/useVerifyCode";
|
||||
import type { UseVerifyEmailReturnType } from "./hooks/useVerifyEmail";
|
||||
|
||||
export type BookingsGetOutput = RouterOutputs["viewer"]["bookings"]["get"];
|
||||
|
||||
@@ -26,3 +36,85 @@ export type BookingRowData = {
|
||||
export type RowData = DataTableRow<BookingRowData>;
|
||||
|
||||
export type BookingListingStatus = (typeof validStatuses)[number];
|
||||
|
||||
export type { UseBookerLayoutType } from "@calcom/features/bookings/Booker/hooks/useBookerLayout";
|
||||
export type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
|
||||
export type { UseBookingsReturnType } from "./hooks/useBookings";
|
||||
export type { UseSlotsReturnType } from "./hooks/useSlots";
|
||||
export type { UseVerifyCodeReturnType } from "./hooks/useVerifyCode";
|
||||
export type { UseVerifyEmailReturnType } from "./hooks/useVerifyEmail";
|
||||
|
||||
export type WrappedBookerPropsMain = {
|
||||
sessionUsername?: string | null;
|
||||
rescheduleUid: string | null;
|
||||
rescheduledBy: string | null;
|
||||
bookingUid: string | null;
|
||||
isRedirect: boolean;
|
||||
fromUserNameRedirected: string;
|
||||
hasSession: boolean;
|
||||
onGoBackInstantMeeting: () => void;
|
||||
onConnectNowInstantMeeting: () => void;
|
||||
onOverlayClickNoCalendar: () => void;
|
||||
onClickOverlayContinue: () => void;
|
||||
onOverlaySwitchStateChange: (state: boolean) => void;
|
||||
extraOptions: Record<string, string | string[]>;
|
||||
bookings: UseBookingsReturnType;
|
||||
slots: UseSlotsReturnType;
|
||||
calendars: {
|
||||
overlayBusyDates?: EventBusyDate[];
|
||||
isOverlayCalendarEnabled: boolean;
|
||||
connectedCalendars: {
|
||||
calendars?: {
|
||||
name?: string;
|
||||
integrationTitle?: string;
|
||||
externalId: string;
|
||||
primary: boolean | null;
|
||||
}[];
|
||||
credentialId: number;
|
||||
delegationCredentialId?: string | null;
|
||||
cacheUpdatedAt: null;
|
||||
error?: {
|
||||
message: string | null;
|
||||
};
|
||||
primary?: {
|
||||
email?: string;
|
||||
};
|
||||
integration: {
|
||||
slug: string;
|
||||
name?: string | undefined;
|
||||
title?: string;
|
||||
logo: string;
|
||||
};
|
||||
}[];
|
||||
loadingConnectedCalendar: boolean;
|
||||
onToggleCalendar: (calendarsToLoad: Set<ToggledConnectedCalendars>) => void;
|
||||
};
|
||||
bookerForm: UseBookingFormReturnType;
|
||||
event: BookerEventQuery;
|
||||
schedule: useScheduleForEventReturnType;
|
||||
bookerLayout: UseBookerLayoutType;
|
||||
verifyEmail: UseVerifyEmailReturnType;
|
||||
customClassNames?: CustomClassNames;
|
||||
isBookingDryRun?: boolean;
|
||||
renderCaptcha?: boolean;
|
||||
confirmButtonDisabled?: boolean;
|
||||
};
|
||||
|
||||
export type WrappedBookerPropsForPlatform = WrappedBookerPropsMain & {
|
||||
isPlatform: true;
|
||||
verifyCode: undefined;
|
||||
customClassNames?: CustomClassNames;
|
||||
timeZones?: import("@calcom/features/bookings/Booker/types").Timezone[];
|
||||
roundRobinHideOrgAndTeam?: boolean;
|
||||
hideOrgTeamAvatar?: boolean;
|
||||
};
|
||||
|
||||
export type WrappedBookerPropsForWeb = WrappedBookerPropsMain & {
|
||||
isPlatform: false;
|
||||
verifyCode: UseVerifyCodeReturnType;
|
||||
timeZones?: import("@calcom/features/bookings/Booker/types").Timezone[];
|
||||
roundRobinHideOrgAndTeam?: boolean;
|
||||
hideOrgTeamAvatar?: boolean;
|
||||
};
|
||||
|
||||
export type WrappedBookerProps = WrappedBookerPropsForPlatform | WrappedBookerPropsForWeb;
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useMemo } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { Calendar } from "@calcom/web/modules/calendars/weeklyview/components/Calendar";
|
||||
import type { CalendarAvailableTimeslots } from "@calcom/features/calendars/weeklyview/types/state";
|
||||
|
||||
@@ -53,7 +53,7 @@ import { Icon } from "@calcom/ui/components/icon";
|
||||
import { HorizontalTabs } from "@calcom/ui/components/navigation";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
import { EmbedTabName, type tabs } from "./EmbedTabs";
|
||||
import { buildCssVarsPerTheme } from "@calcom/features/embed/lib/buildCssVarsPerTheme";
|
||||
import { EmbedTheme } from "@calcom/features/embed/lib/constants";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/components/hooks/useAvailableTimeSlots";
|
||||
import { useAvailableTimeSlots } from "@calcom/features/bookings/Booker/hooks/useAvailableTimeSlots";
|
||||
import { useTimePreferences } from "@calcom/features/bookings/lib/timePreferences";
|
||||
import { useSchedule } from "@calcom/features/schedules/lib/use-schedule/useSchedule";
|
||||
import { useTroubleshooterStore } from "@calcom/features/troubleshooter/store";
|
||||
|
||||
Reference in new issue
Block a user