From bd21b2dfe1c68b825734a017c01082ce6207a0a4 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Thu, 14 Sep 2023 16:47:25 -0300 Subject: [PATCH] fix: Import prisma (#11369) Co-authored-by: zomars --- apps/web/playwright/login.2fa.e2e.ts | 5 +++-- packages/features/ee/payments/api/paypal-webhook.ts | 4 ++-- .../availability/schedule/getScheduleByUserId.handler.ts | 5 ++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/web/playwright/login.2fa.e2e.ts b/apps/web/playwright/login.2fa.e2e.ts index 6b1e588c4c..4a57ba26bb 100644 --- a/apps/web/playwright/login.2fa.e2e.ts +++ b/apps/web/playwright/login.2fa.e2e.ts @@ -4,6 +4,7 @@ import { authenticator } from "otplib"; import { symmetricDecrypt } from "@calcom/lib/crypto"; import { totpAuthenticatorCheck } from "@calcom/lib/totp"; +import { prisma } from "@calcom/prisma"; import { test } from "./lib/fixtures"; @@ -61,7 +62,7 @@ test.describe("2FA Tests", async () => { await test.step("Login with 2FA enabled", async () => { await user.login(); - const userWith2FaSecret = await prisma?.user.findFirst({ + const userWith2FaSecret = await prisma.user.findFirst({ where: { id: user.id, }, @@ -138,7 +139,7 @@ test.describe("2FA Tests", async () => { await page.click(`[data-testid=two-factor-switch][data-state="checked"]`); await page.fill('input[name="password"]', userPassword); - const userWith2FaSecret = await prisma?.user.findFirst({ + const userWith2FaSecret = await prisma.user.findFirst({ where: { id: user.id, }, diff --git a/packages/features/ee/payments/api/paypal-webhook.ts b/packages/features/ee/payments/api/paypal-webhook.ts index 06c5588795..81531745ae 100644 --- a/packages/features/ee/payments/api/paypal-webhook.ts +++ b/packages/features/ee/payments/api/paypal-webhook.ts @@ -300,7 +300,7 @@ export const findPaymentCredentials = async ( ): Promise<{ clientId: string; secretKey: string; webhookId: string }> => { try { // @TODO: what about team bookings with paypal? - const userFromBooking = await prisma?.booking.findFirst({ + const userFromBooking = await prisma.booking.findFirst({ where: { id: bookingId, }, @@ -312,7 +312,7 @@ export const findPaymentCredentials = async ( if (!userFromBooking) throw new Error("No user found"); - const credentials = await prisma?.credential.findFirst({ + const credentials = await prisma.credential.findFirst({ where: { appId: "paypal", userId: userFromBooking?.userId, diff --git a/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByUserId.handler.ts b/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByUserId.handler.ts index 1313251652..927ddeb4a1 100644 --- a/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByUserId.handler.ts +++ b/packages/trpc/server/routers/viewer/availability/schedule/getScheduleByUserId.handler.ts @@ -1,3 +1,5 @@ +import type { PrismaClient } from "@calcom/prisma"; + import type { TrpcSessionUser } from "../../../../trpc"; import { getHandler } from "./get.handler"; import type { TGetByUserIdInputSchema } from "./getScheduleByUserId.schema"; @@ -5,6 +7,7 @@ import type { TGetByUserIdInputSchema } from "./getScheduleByUserId.schema"; type GetOptions = { ctx: { user: NonNullable; + prisma: PrismaClient; }; input: TGetByUserIdInputSchema; }; @@ -12,7 +15,7 @@ type GetOptions = { const EMPTY_SCHEDULE = [[], [], [], [], [], [], []]; export const getScheduleByUserIdHandler = async ({ ctx, input }: GetOptions) => { - const foundUserDefaultId = await prisma.user.findUnique({ + const foundUserDefaultId = await ctx.prisma.user.findUnique({ where: { id: input.userId, },