Skip to content

Commit 71515ad

Browse files
refactor: remove tRPC references from packages/lib (calcom#24553)
1 parent 66234ff commit 71515ad

50 files changed

Lines changed: 235 additions & 211 deletions

File tree

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/(use-page-wrapper)/apps/routing-forms/forms/[[...pages]]/Forms.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useFormContext } from "react-hook-form";
66

77
import { isFallbackRoute } from "@calcom/app-store/routing-forms/lib/isFallbackRoute";
88
import type { RoutingFormWithResponseCount } from "@calcom/app-store/routing-forms/types/types";
9+
import { useHasPaidPlan } from "@calcom/features/billing/hooks/useHasPaidPlan";
910
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
1011
import SkeletonLoaderTeamList from "@calcom/features/ee/teams/components/SkeletonloaderTeamList";
1112
import { CreateButtonWithTeamsList } from "@calcom/features/ee/teams/components/createButton/CreateButtonWithTeamsList";
@@ -15,7 +16,6 @@ import { getTeamsFiltersFromQuery } from "@calcom/features/filters/lib/getTeamsF
1516
import { ShellMain } from "@calcom/features/shell/Shell";
1617
import { UpgradeTip } from "@calcom/features/tips";
1718
import { WEBAPP_URL } from "@calcom/lib/constants";
18-
import { useHasPaidPlan } from "@calcom/lib/hooks/useHasPaidPlan";
1919
import { useLocale } from "@calcom/lib/hooks/useLocale";
2020
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
2121
import { MembershipRole } from "@calcom/prisma/enums";

apps/web/app/api/defaultResponderForAppDir.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ import { ApiError } from "next/dist/server/api-utils";
33
import type { NextRequest } from "next/server";
44
import { NextResponse } from "next/server";
55

6+
import { HttpError } from "@calcom/lib/http-error";
67
import { getServerErrorFromUnknown } from "@calcom/lib/server/getServerErrorFromUnknown";
78
import { performance } from "@calcom/lib/server/perfObserver";
89

10+
import { TRPCError } from "@trpc/server";
11+
import { getHTTPStatusCodeFromError } from "@trpc/server/http";
12+
913
type Handler<T extends NextResponse | Response = NextResponse> = (
1014
req: NextRequest,
1115
{ params }: { params: Promise<Params> }
@@ -34,15 +38,18 @@ export const defaultResponderForAppDir = <T extends NextResponse | Response = Ne
3438

3539
return NextResponse.json({});
3640
} catch (error) {
37-
let serverError;
41+
let serverError: HttpError;
3842

39-
if (error instanceof ApiError) {
40-
serverError = {
43+
if (error instanceof TRPCError) {
44+
const statusCode = getHTTPStatusCodeFromError(error);
45+
serverError = new HttpError({ statusCode, message: error.message });
46+
} else if (error instanceof ApiError) {
47+
serverError = new HttpError({
4148
message: error.message,
4249
statusCode: error.statusCode,
4350
url: req.url,
4451
method: req.method,
45-
};
52+
});
4653
} else {
4754
serverError = getServerErrorFromUnknown(error);
4855
}

packages/app-store/_components/OmniInstallAppButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import useApp from "@calcom/lib/hooks/useApp";
1+
import useApp from "@calcom/features/apps/hooks/useApp";
22
import { useLocale } from "@calcom/lib/hooks/useLocale";
33
import classNames from "@calcom/ui/classNames";
44
import { Button } from "@calcom/ui/components/button";

packages/lib/hooks/useHasPaidPlan.ts renamed to packages/features/billing/hooks/useHasPaidPlan.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import { IS_SELF_HOSTED } from "@calcom/lib/constants";
2+
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
13
import { trpc } from "@calcom/trpc/react";
24

3-
import { IS_SELF_HOSTED } from "../constants";
4-
import hasKeyInMetadata from "../hasKeyInMetadata";
5-
65
export function useHasPaidPlan() {
76
if (IS_SELF_HOSTED) return { isPending: false, hasPaidPlan: true };
87

packages/features/di/modules/Schedule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DI_TOKENS } from "@calcom/features/di/tokens";
2-
import { ScheduleRepository } from "@calcom/lib/server/repository/schedule";
2+
import { ScheduleRepository } from "@calcom/features/schedules/repositories/ScheduleRepository";
33

44
import { createModule } from "../di";
55

packages/features/ee/organizations/pages/components/OtherTeamList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useState } from "react";
44

55
import type { OrganizationRepository } from "@calcom/features/ee/organizations/repositories/OrganizationRepository";
6-
import { trackFormbricksAction } from "@calcom/lib/formbricks-client";
6+
import { trackFormbricksAction } from "@calcom/features/formbricks/formbricks-client";
77
import { trpc } from "@calcom/trpc/react";
88
import { showToast } from "@calcom/ui/components/toast";
99

packages/features/ee/organizations/pages/settings/other-team-profile-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { Controller, useForm } from "react-hook-form";
99
import { z } from "zod";
1010

1111
import { Dialog } from "@calcom/features/components/controlled-dialog";
12+
import { trackFormbricksAction } from "@calcom/features/formbricks/formbricks-client";
1213
import { IS_TEAM_BILLING_ENABLED_CLIENT, WEBAPP_URL } from "@calcom/lib/constants";
1314
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
14-
import { trackFormbricksAction } from "@calcom/lib/formbricks-client";
1515
import { useLocale } from "@calcom/lib/hooks/useLocale";
1616
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
1717
import { md } from "@calcom/lib/markdownIt";

packages/features/ee/support/components/ContactMenuItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { useHasPaidPlan } from "@calcom/features/billing/hooks/useHasPaidPlan";
12
import { JOIN_COMMUNITY } from "@calcom/lib/constants";
2-
import { useHasPaidPlan } from "@calcom/lib/hooks/useHasPaidPlan";
33
import { useLocale } from "@calcom/lib/hooks/useLocale";
44
import { UpgradeTeamsBadge } from "@calcom/ui/components/badge";
55
import { Icon } from "@calcom/ui/components/icon";

packages/features/ee/support/lib/intercom/provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { useEffect, type FC } from "react";
66
import { IntercomProvider } from "react-use-intercom";
77

88
import { useBootIntercom } from "@calcom/ee/support/lib/intercom/useIntercom";
9+
import useHasPaidPlan from "@calcom/features/billing/hooks/useHasPaidPlan";
910
import { IntercomContactForm } from "@calcom/features/ee/support/components/IntercomContactForm";
1011
import { useFlagMap } from "@calcom/features/flags/context/provider";
11-
import useHasPaidPlan from "@calcom/lib/hooks/useHasPaidPlan";
1212
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
1313

1414
declare global {

0 commit comments

Comments
 (0)