refactor: remove 6 @calcom/trpc imports from packages/features (#27727)

* migrate booker layout selector

* move schedule hooks and types

* migrate feature opt in components

* migrate feedback dialog

* update

* migrate schedule hooks

* migrate useSegments

* update

* update import paths

* fix import paths

* mv useTimesForSchedule back to features

* fix
This commit is contained in:
Benny Joo
2026-02-07 09:05:09 -03:00
committed by GitHub
parent aa5e90ab2a
commit e64fad8e34
43 changed files with 68 additions and 45 deletions
@@ -8,9 +8,9 @@ import {
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
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";
import { useSlotsForAvailableDates } from "@calcom/features/schedules/lib/use-schedule/useSlotsForDate";
import type { Slot } from "~/schedules/lib/types";
import { useNonEmptyScheduleDays } from "@calcom/web/modules/schedules/hooks/useNonEmptyScheduleDays";
import { useSlotsForAvailableDates } from "@calcom/web/modules/schedules/hooks/useSlotsForDate";
import { PUBLIC_INVALIDATE_AVAILABLE_SLOTS_ON_BOOKING_FORM } from "@calcom/lib/constants";
import { localStorage } from "@calcom/lib/webstorage";
import { BookerLayouts } from "@calcom/prisma/zod-utils";
@@ -11,7 +11,7 @@ import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerSt
import { OutOfOfficeInSlots } from "./OutOfOfficeInSlots";
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 type { Slot } from "~/schedules/lib/types";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { localStorage } from "@calcom/lib/webstorage";
import classNames from "@calcom/ui/classNames";
@@ -20,7 +20,7 @@ import { isBookingDryRun } from "@calcom/features/bookings/Booker/utils/isBookin
import { isTimeSlotAvailable } from "@calcom/features/bookings/Booker/utils/isTimeslotAvailable";
import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { useNonEmptyScheduleDays } from "@calcom/features/schedules/lib/use-schedule/useNonEmptyScheduleDays";
import { useNonEmptyScheduleDays } from "@calcom/web/modules/schedules/hooks/useNonEmptyScheduleDays";
import { scrollIntoViewSmooth } from "@calcom/lib/browser/browser.utils";
import {
CLOUDFLARE_SITE_ID,
@@ -5,7 +5,7 @@ import dayjs from "@calcom/dayjs";
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
import type { DatePickerClassNames } from "@calcom/features/bookings/Booker/types";
import { DatePicker as DatePickerComponent } from "@calcom/features/calendars/components/DatePicker";
import { useNonEmptyScheduleDays } from "@calcom/features/schedules/lib/use-schedule/useNonEmptyScheduleDays";
import { useNonEmptyScheduleDays } from "@calcom/web/modules/schedules/hooks/useNonEmptyScheduleDays";
import { weekdayToWeekIndex } from "@calcom/lib/dayjs";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { User } from "@calcom/prisma/client";
@@ -1,8 +1,8 @@
"use client";
import { ColumnFilterType, DataTableProvider, type SystemFilterSegment } from "@calcom/features/data-table";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import FeatureOptInBannerWrapper from "@calcom/features/feature-opt-in/components/FeatureOptInBannerWrapper";
import { useSegments } from "~/data-table/hooks/useSegments";
import FeatureOptInBannerWrapper from "~/feature-opt-in/components/FeatureOptInBannerWrapper";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import classNames from "@calcom/ui/classNames";
import dynamic from "next/dynamic";
@@ -2,9 +2,9 @@ import { useMemo } from "react";
import { trpc } from "@calcom/trpc/react";
import { recalculateDateRange } from "../lib/dateRange";
import { type UseSegments, SYSTEM_SEGMENT_PREFIX } from "../lib/types";
import { isDateRangeFilterValue } from "../lib/utils";
import { recalculateDateRange } from "@calcom/features/data-table/lib/dateRange";
import { type UseSegments, SYSTEM_SEGMENT_PREFIX } from "@calcom/features/data-table/lib/types";
import { isDateRangeFilterValue } from "@calcom/features/data-table/lib/utils";
export const useSegments: UseSegments = ({ tableIdentifier, providedSegments, systemSegments }) => {
const { data: rawSegments, isSuccess } = trpc.viewer.filterSegments.list.useQuery(
@@ -1,6 +1,6 @@
"use client";
import { FeaturesSettings } from "@calcom/features/feature-opt-in/components/FeaturesSettings";
import { FeaturesSettings } from "~/feature-opt-in/components/FeaturesSettings";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { ReactElement } from "react";
@@ -3,7 +3,7 @@
import { usePathname } from "next/navigation";
import { DataTableProvider } from "@calcom/features/data-table";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import LicenseRequired from "~/ee/common/components/LicenseRequired";
import OrgAutoJoinSetting from "~/ee/organizations/components/OrgAutoJoinSetting";
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -4,7 +4,7 @@ import { useMemo, useState, useCallback } from "react";
import { DataTableProvider } from "@calcom/features/data-table";
import { DataTableWrapper } from "~/data-table/components";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import { useVoicePreview } from "@calcom/features/ee/workflows/hooks/useVoicePreview";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
+3 -3
View File
@@ -25,9 +25,9 @@ import {
import DatePicker from "@calcom/features/calendars/components/DatePicker";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { TimezoneSelect } from "@calcom/web/modules/timezone/components/TimezoneSelect";
import type { Slot } from "@calcom/features/schedules/lib/use-schedule/types";
import { useNonEmptyScheduleDays } from "@calcom/features/schedules/lib/use-schedule/useNonEmptyScheduleDays";
import { useSlotsForDate } from "@calcom/features/schedules/lib/use-schedule/useSlotsForDate";
import type { Slot } from "~/schedules/lib/types";
import { useNonEmptyScheduleDays } from "@calcom/web/modules/schedules/hooks/useNonEmptyScheduleDays";
import { useSlotsForDate } from "@calcom/web/modules/schedules/hooks/useSlotsForDate";
import {
APP_NAME,
DEFAULT_LIGHT_BRAND_COLOR,
@@ -6,7 +6,7 @@ import type {
SettingsToggleClassNames,
TeamMember,
} from "@calcom/features/eventtypes/lib/types";
import { Segment } from "@calcom/features/Segment";
import { Segment } from "./Segment";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
import { Label, SettingsToggle } from "@calcom/ui/components/form";
@@ -3,7 +3,7 @@ import React from "react";
import { describe, expect, it, vi, beforeEach } from "vitest";
import type { Mock } from "vitest";
import { Segment } from "@calcom/features/Segment";
import { Segment } from "./Segment";
import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
import { AttributeType } from "@calcom/prisma/enums";
import { trpc, type RouterOutputs } from "@calcom/trpc/react";
@@ -14,7 +14,7 @@ vi.mock("@formkit/auto-animate/react", () => ({
}));
// Mock Segment component
vi.mock("@calcom/features/Segment", () => ({
vi.mock("@calcom/web/modules/event-types/components/Segment", () => ({
Segment: vi.fn().mockImplementation(({ onQueryValueChange }) => (
<div data-testid="mock-segment">
<button onClick={() => onQueryValueChange({ queryValue: { id: "test" } })}>Update Query</button>
@@ -34,7 +34,7 @@ import type {
SettingsToggleClassNames,
} from "@calcom/features/eventtypes/lib/types";
import { FormBuilder } from "./FormBuilder";
import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
import { BookerLayoutSelector } from "~/settings/components/BookerLayoutSelector";
import {
DEFAULT_LIGHT_BRAND_COLOR,
DEFAULT_DARK_BRAND_COLOR,
@@ -1,7 +1,7 @@
"use client";
import type { OptInFeatureConfig } from "@calcom/features/feature-opt-in/config";
import { FeedbackDialog } from "@calcom/features/feedback/components/FeedbackDialog";
import { FeedbackDialog } from "./FeedbackDialog";
import type { ReactElement } from "react";
import { createPortal } from "react-dom";
import { FeatureOptInBanner } from "./FeatureOptInBanner";
@@ -11,8 +11,8 @@ import { Tooltip } from "@calcom/ui/components/tooltip";
import type { ReactElement } from "react";
import { useMemo } from "react";
import { getOptInFeatureConfig } from "../config";
import type { NormalizedFeature, UseFeatureOptInResult } from "../types";
import { getOptInFeatureConfig } from "@calcom/features/feature-opt-in/config";
import type { NormalizedFeature, UseFeatureOptInResult } from "@calcom/features/feature-opt-in/types";
interface FeaturesSettingsProps {
/** The hook result - can be from useUserFeatureOptIn, useTeamFeatureOptIn, or useOrganizationFeatureOptIn */
@@ -9,7 +9,7 @@ import { cn } from "@coss/ui/lib/utils";
import { XIcon } from "lucide-react";
import type { ReactElement } from "react";
import { useState } from "react";
import { RATING_OPTIONS } from "../../bookings/lib/rating";
import { RATING_OPTIONS } from "@calcom/features/bookings/lib/rating";
export interface FeedbackDialogProps {
isOpen: boolean;
@@ -20,7 +20,7 @@ import {
DataTableToolbar,
DataTableFilters,
} from "~/data-table/components";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import type {
CallDetailsState,
@@ -3,7 +3,7 @@
import { usePathname } from "next/navigation";
import { DataTableProvider } from "@calcom/features/data-table/DataTableProvider";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import {
RoutingFormResponsesTable,
FailedBookingsByField,
@@ -11,7 +11,7 @@ import {
import { DataTableFilters, DateRangeFilter } from "~/data-table/components";
import type { FilterType } from "@calcom/types/data-table";
import { useDataTable } from "@calcom/features/data-table/hooks/useDataTable";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import {
AverageEventDurationChart,
BookingKPICards,
@@ -1,8 +1,8 @@
import { useMemo } from "react";
import type { Slots } from "../use-schedule/types";
import type { Slots } from "../lib/types";
export const getNonEmptyScheduleDays = (slots?: Slots) => {
const getNonEmptyScheduleDays = (slots?: Slots) => {
if (typeof slots === "undefined") return [];
const nonEmptyDays: string[] = [];
@@ -5,7 +5,7 @@ import { sdkActionManager } from "@calcom/embed-core/src/sdk-event";
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
import { isBookingDryRun } from "@calcom/features/bookings/Booker/utils/isBookingDryRun";
import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents";
import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule";
import { useTimesForSchedule } from "@calcom/features/schedules/hooks/useTimesForSchedule";
import { getRoutedTeamMemberIdsFromSearchParams } from "@calcom/lib/bookings/getRoutedTeamMemberIdsFromSearchParams";
import { PUBLIC_QUERY_AVAILABLE_SLOTS_INTERVAL_SECONDS } from "@calcom/lib/constants";
import { trpc } from "@calcom/trpc/react";
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useState } from "react";
import type { Slots, Slot } from "./types";
import type { Slots, Slot } from "../lib/types";
/**
* Gets slots for a specific date from the schedule cache.
@@ -13,7 +13,7 @@ import {
ZDateRangeFilterValue,
type FilterableColumn,
} from "@calcom/features/data-table";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import type { FilterType } from "@calcom/types/data-table";
@@ -13,7 +13,7 @@ import { Button } from "@calcom/ui/components/button";
import { Label } from "@calcom/ui/components/form";
import { CheckboxField } from "@calcom/ui/components/form";
import SectionBottomActions from "./SectionBottomActions";
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
type BookerLayoutSelectorProps = {
title?: string;
@@ -7,7 +7,7 @@ import { useState } from "react";
import { Controller, useForm } from "react-hook-form";
import type { z } from "zod";
import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
import { BookerLayoutSelector } from "~/settings/components/BookerLayoutSelector";
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
@@ -1,6 +1,6 @@
"use client";
import { FeaturesSettings } from "@calcom/features/feature-opt-in/components/FeaturesSettings";
import { FeaturesSettings } from "~/feature-opt-in/components/FeaturesSettings";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { ReactElement } from "react";
@@ -19,7 +19,7 @@ import {
ZDateRangeFilterValue,
} from "@calcom/features/data-table";
import { DataTableWrapper, DataTableToolbar, DataTableFilters, DataTableSegment } from "~/data-table/components";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import ServerTrans from "@calcom/lib/components/ServerTrans";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
@@ -1,6 +1,6 @@
"use client";
import { FeaturesSettings } from "@calcom/features/feature-opt-in/components/FeaturesSettings";
import { FeaturesSettings } from "~/feature-opt-in/components/FeaturesSettings";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { ReactElement } from "react";
@@ -1,7 +1,7 @@
import dayjs from "@calcom/dayjs";
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 { useSchedule } from "~/schedules/hooks/useSchedule";
import { useTroubleshooterStore } from "@calcom/features/troubleshooter/store";
import { BookingStatus } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
@@ -10,7 +10,7 @@ import {
useDataTable,
} from "@calcom/features/data-table";
import { DataTableWrapper, DataTableToolbar, DataTableFilters, DataTableSegment, DataTableSelectionBar } from "~/data-table/components";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
@@ -9,7 +9,7 @@ import {
useColumnFilters,
useDataTable,
} from "@calcom/features/data-table";
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
import { useSegments } from "~/data-table/hooks/useSegments";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
import { WEBAPP_URL } from "@calcom/lib/constants";
@@ -1,7 +1,7 @@
import { shallow } from "zustand/shallow";
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
import { useSchedule } from "@calcom/features/schedules/lib/use-schedule/useSchedule";
import { useSchedule } from "~/schedules/hooks/useSchedule";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { trpc } from "@calcom/trpc/react";
@@ -6,7 +6,30 @@ import type { BookerState } from "@calcom/features/bookings/Booker/types";
import { getPrefetchMonthCount } from "@calcom/features/bookings/Booker/utils/getPrefetchMonthCount";
import { isPrefetchNextMonthEnabled } from "@calcom/features/bookings/Booker/utils/isPrefetchNextMonthEnabled";
import type { UseScheduleWithCacheArgs } from "./useSchedule";
type UseScheduleWithCacheArgs = {
username?: string | null;
eventSlug?: string | null;
eventId?: number | null;
month?: string | null;
timezone?: string | null;
selectedDate?: string | null;
duration?: number | null;
dayCount?: number | null;
rescheduleUid?: string | null;
isTeamEvent?: boolean;
orgSlug?: string;
teamMemberEmail?: string | null;
useApiV2?: boolean;
enabled?: boolean;
/***
* Required when prefetching is needed
*/
bookerLayout?: {
layout: string;
extraDays: number;
columnViewExtraDays: { current: number };
};
};
type UseTimesForScheduleProps = Pick<
UseScheduleWithCacheArgs,
@@ -14,7 +14,7 @@ import { useInitializeBookerStore } from "@calcom/features/bookings/Booker/store
import { useTimePreferences } from "@calcom/features/bookings/lib";
import type { ConnectedDestinationCalendars } from "@calcom/features/calendars/lib/getConnectedDestinationCalendars";
import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents";
import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule";
import { useTimesForSchedule } from "@calcom/features/schedules/hooks/useTimesForSchedule";
import { getRoutedTeamMemberIdsFromSearchParams } from "@calcom/lib/bookings/getRoutedTeamMemberIdsFromSearchParams";
import { localStorage } from "@calcom/lib/webstorage";
import { BookerLayouts } from "@calcom/prisma/zod-utils";
@@ -12,7 +12,7 @@ import { useBookerLayout } from "@calcom/features/bookings/Booker/hooks/useBooke
import { useTimePreferences } from "@calcom/features/bookings/lib";
import { LargeCalendar } from "@calcom/web/modules/calendar-view/components/LargeCalendar";
import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents";
import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule";
import { useTimesForSchedule } from "@calcom/features/schedules/hooks/useTimesForSchedule";
import { formatUsername } from "../booker/BookerPlatformWrapper";
import type {