Skip to content

Commit 73f5192

Browse files
refactor: move Booker hooks from packages/features to apps/web/modules (calcom#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: benny@cal.com <sldisek783@gmail.com> * 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: benny@cal.com <sldisek783@gmail.com> * fix: use @calcom/web alias for hook imports to fix vitest resolution Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * 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: benny@cal.com <sldisek783@gmail.com> * fix * fix * fix * revert: restore original import ordering in moved hooks Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * 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>
1 parent 5476c38 commit 73f5192

46 files changed

Lines changed: 213 additions & 213 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/web/app/(booking-page-wrapper)/booking-successful/[uid]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useParams } from "next/navigation";
44

55
import dayjs from "@calcom/dayjs";
66
import { DecoyBookingSuccessCard } from "~/bookings/components/DecoyBookingSuccessCard";
7-
import { useDecoyBooking } from "@calcom/features/bookings/Booker/components/hooks/useDecoyBooking";
7+
import { useDecoyBooking } from "~/bookings/hooks/useDecoyBooking";
88

99
export default function BookingSuccessful() {
1010
const params = useParams();

apps/web/modules/bookings/components/AvailableTimeSlots.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
AvailableTimesSkeleton,
77
} from "@calcom/web/modules/bookings/components/AvailableTimes";
88
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
9-
import type { IUseBookingLoadingStates } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
9+
import type { IUseBookingLoadingStates } from "../hooks/useBookings";
1010
import type { BookerEvent } from "@calcom/features/bookings/types";
1111
import type { Slot } from "@calcom/features/schedules/lib/use-schedule/types";
1212
import { useNonEmptyScheduleDays } from "@calcom/features/schedules/lib/use-schedule/useNonEmptyScheduleDays";

apps/web/modules/bookings/components/AvailableTimes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import dayjs from "@calcom/dayjs";
99
import type { IOutOfOfficeData } from "@calcom/features/availability/lib/getUserAvailability";
1010
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
1111
import { OutOfOfficeInSlots } from "./OutOfOfficeInSlots";
12-
import type { IUseBookingLoadingStates } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
12+
import type { IUseBookingLoadingStates } from "../hooks/useBookings";
1313
import type { BookerEvent } from "@calcom/features/bookings/types";
1414
import type { Slot } from "@calcom/features/schedules/lib/use-schedule/types";
1515
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -19,7 +19,7 @@ import { Button } from "@calcom/ui/components/button";
1919
import { Icon } from "@calcom/ui/components/icon";
2020
import { SkeletonText } from "@calcom/ui/components/skeleton";
2121

22-
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
22+
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
2323
import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
2424
import { useCheckOverlapWithOverlay } from "@calcom/features/bookings/lib/useCheckOverlapWithOverlay";
2525
import type { Slots } from "@calcom/features/bookings/types";

apps/web/modules/bookings/components/BookEventForm/BookEventForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import { EmptyScreen } from "@calcom/ui/components/empty-screen";
1818
import { Form } from "@calcom/ui/components/form";
1919

2020
import { formatEventFromTime } from "@calcom/features/bookings/Booker/utils/dates";
21-
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
22-
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm";
23-
import type { IUseBookingErrors, IUseBookingLoadingStates } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
21+
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
22+
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
23+
import type { IUseBookingErrors, IUseBookingLoadingStates } from "../../hooks/useBookings";
2424
import { BookingFields } from "./BookingFields";
2525
import { FormSkeleton } from "./Skeleton";
2626

apps/web/modules/bookings/components/BookEventForm/BookFormAsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { DialogContent } from "@calcom/ui/components/dialog";
1212
import { getDurationFormatted } from "../event-meta/Duration";
1313
import { FromTime } from "@calcom/features/bookings/Booker/utils/dates";
1414
import { useEvent } from "@calcom/features/bookings/Booker/utils/event";
15-
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
15+
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
1616

1717
const BookEventFormWrapper = ({ children, onCancel }: { onCancel: () => void; children: ReactNode }) => {
1818
const { data } = useEvent();

apps/web/modules/bookings/components/Booker.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import "@calcom/dayjs/__mocks__";
3535
import "@calcom/web/modules/auth/components/Turnstile";
3636

3737
import { render, screen } from "@calcom/features/bookings/Booker/__tests__/test-utils";
38-
import type { BookerProps, WrappedBookerProps } from "@calcom/features/bookings/Booker/types";
38+
import type { BookerProps } from "@calcom/features/bookings/Booker/types";
39+
import type { WrappedBookerProps } from "../types";
3940
import { Booker } from "./Booker";
4041

4142
vi.mock("framer-motion", async (importOriginal) => {

apps/web/modules/bookings/components/Booker.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import { useEmbedUiConfig } from "@calcom/embed-core/embed-iframe";
66
import { updateEmbedBookerState } from "@calcom/embed-core/src/embed-iframe";
77
import TurnstileCaptcha from "@calcom/web/modules/auth/components/Turnstile";
88
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
9-
import { useIsQuickAvailabilityCheckFeatureEnabled } from "@calcom/features/bookings/Booker/components/hooks/useIsQuickAvailabilityCheckFeatureEnabled";
10-
import useSkipConfirmStep from "@calcom/features/bookings/Booker/components/hooks/useSkipConfirmStep";
9+
import { useIsQuickAvailabilityCheckFeatureEnabled } from "../hooks/useIsQuickAvailabilityCheckFeatureEnabled";
10+
import { useSkipConfirmStep } from "@calcom/web/modules/bookings/hooks/useSkipConfirmStep";
1111
import {
1212
fadeInLeft,
1313
getBookerSizeClassNames,
1414
useBookerResizeAnimation,
1515
} from "@calcom/features/bookings/Booker/config";
1616
import framerFeatures from "@calcom/features/bookings/Booker/framer-features";
17-
import type { BookerProps, WrappedBookerProps } from "@calcom/features/bookings/Booker/types";
17+
import type { BookerProps } from "@calcom/features/bookings/Booker/types";
18+
import type { WrappedBookerProps } from "../types";
1819
import { isBookingDryRun } from "@calcom/features/bookings/Booker/utils/isBookingDryRun";
1920
import { isTimeSlotAvailable } from "@calcom/features/bookings/Booker/utils/isTimeslotAvailable";
2021
import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";

apps/web/modules/bookings/components/BookerWebWrapper.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import {
88
useBookerStoreContext,
99
useInitializeBookerStoreContext,
1010
} from "@calcom/features/bookings/Booker/BookerStoreProvider";
11-
import { useBookerLayout } from "@calcom/features/bookings/Booker/components/hooks/useBookerLayout";
12-
import { useBookingForm } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm";
13-
import { useBookings } from "@calcom/features/bookings/Booker/components/hooks/useBookings";
14-
import { useCalendars } from "@calcom/features/bookings/Booker/components/hooks/useCalendars";
15-
import { useSlots } from "@calcom/features/bookings/Booker/components/hooks/useSlots";
16-
import { useVerifyCode } from "@calcom/features/bookings/Booker/components/hooks/useVerifyCode";
17-
import { useVerifyEmail } from "@calcom/features/bookings/Booker/components/hooks/useVerifyEmail";
11+
import { useBookerLayout } from "@calcom/features/bookings/Booker/hooks/useBookerLayout";
12+
import { useBookingForm } from "@calcom/features/bookings/Booker/hooks/useBookingForm";
13+
import { useBookings } from "../hooks/useBookings";
14+
import { useCalendars } from "../hooks/useCalendars";
15+
import { useSlots } from "../hooks/useSlots";
16+
import { useVerifyCode } from "../hooks/useVerifyCode";
17+
import { useVerifyEmail } from "../hooks/useVerifyEmail";
1818
import { useInitializeBookerStore } from "@calcom/features/bookings/Booker/store";
1919
import { useEvent, useScheduleForEvent } from "@calcom/features/bookings/Booker/utils/event";
2020
import { useBrandColors } from "@calcom/features/bookings/Booker/utils/use-brand-colors";

apps/web/modules/bookings/components/DatePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { weekdayToWeekIndex } from "@calcom/lib/dayjs";
1010
import { useLocale } from "@calcom/lib/hooks/useLocale";
1111
import type { User } from "@calcom/prisma/client";
1212
import type { PeriodData } from "@calcom/types/Event";
13-
import { useSlotsViewOnSmallScreen } from "@calcom/features/bookings/Booker/components/hooks/useSlotsViewOnSmallScreen";
13+
import { useSlotsViewOnSmallScreen } from "@calcom/embed-core/embed-iframe";
1414

1515
import type { Slots } from "@calcom/features/bookings/types";
1616

apps/web/modules/bookings/components/EventMeta.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Timezone as PlatformTimezoneSelect } from "@calcom/atoms/timezone";
22
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
3-
import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";
3+
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
44
import { fadeInUp } from "@calcom/features/bookings/Booker/config";
55
import type { Timezone } from "@calcom/features/bookings/Booker/types";
66
import { FromToTime } from "@calcom/features/bookings/Booker/utils/dates";

0 commit comments

Comments
 (0)