diff --git a/apps/web/playwright/apps/conferencing/conferencingApps.e2e.ts b/apps/web/playwright/apps/conferencing/conferencingApps.e2e.ts index 890670dfdf..dc88624d57 100644 --- a/apps/web/playwright/apps/conferencing/conferencingApps.e2e.ts +++ b/apps/web/playwright/apps/conferencing/conferencingApps.e2e.ts @@ -1,11 +1,5 @@ import { test } from "../../lib/fixtures"; - -export type TApp = { - slug: string; - type: string; - organizerInputPlaceholder?: string; - label: string; -}; +import type { TApp } from "./types"; const APP: TApp = { slug: "around", diff --git a/apps/web/playwright/apps/conferencing/types.ts b/apps/web/playwright/apps/conferencing/types.ts new file mode 100644 index 0000000000..a33c137d01 --- /dev/null +++ b/apps/web/playwright/apps/conferencing/types.ts @@ -0,0 +1,6 @@ +export type TApp = { + slug: string; + type: string; + organizerInputPlaceholder?: string; + label: string; +}; diff --git a/apps/web/playwright/availability.e2e.ts b/apps/web/playwright/availability.e2e.ts index f4fb63c534..03fb165f93 100644 --- a/apps/web/playwright/availability.e2e.ts +++ b/apps/web/playwright/availability.e2e.ts @@ -3,7 +3,8 @@ import { expect } from "@playwright/test"; import dayjs from "@calcom/dayjs"; import { test } from "./lib/fixtures"; -import { localize, submitAndWaitForResponse } from "./lib/testUtils"; +import { localize } from "./lib/localize"; +import { submitAndWaitForResponse } from "./lib/testUtils"; test.describe.configure({ mode: "parallel" }); diff --git a/apps/web/playwright/fixtures/apps.ts b/apps/web/playwright/fixtures/apps.ts index bda5c11c70..955474a4f7 100644 --- a/apps/web/playwright/fixtures/apps.ts +++ b/apps/web/playwright/fixtures/apps.ts @@ -1,6 +1,6 @@ import { expect, type Page } from "@playwright/test"; -import type { TApp } from "../apps/conferencing/conferencingApps.e2e"; +import type { TApp } from "../apps/conferencing/types"; import { bookTimeSlot, gotoBookingPage, diff --git a/apps/web/playwright/fixtures/eventTypes.ts b/apps/web/playwright/fixtures/eventTypes.ts index 3124dd821c..6a76220d88 100644 --- a/apps/web/playwright/fixtures/eventTypes.ts +++ b/apps/web/playwright/fixtures/eventTypes.ts @@ -1,6 +1,6 @@ import { expect, type Page } from "@playwright/test"; -import { localize } from "../lib/testUtils"; +import { localize } from "../lib/localize"; export function createEventTypeFixture(page: Page) { return { diff --git a/apps/web/playwright/fixtures/regularBookings.ts b/apps/web/playwright/fixtures/regularBookings.ts index 61ea24c4f1..b587a5947e 100644 --- a/apps/web/playwright/fixtures/regularBookings.ts +++ b/apps/web/playwright/fixtures/regularBookings.ts @@ -2,7 +2,8 @@ import { expect, type Page } from "@playwright/test"; import type { MembershipRole } from "@calcom/prisma/enums"; -import { localize, submitAndWaitForResponse } from "../lib/testUtils"; +import { localize } from "../lib/localize"; +import { submitAndWaitForResponse } from "../lib/testUtils"; import type { createUsersFixture } from "./users"; export const scheduleSuccessfullyText = "This meeting is scheduled"; diff --git a/apps/web/playwright/fixtures/workflows.ts b/apps/web/playwright/fixtures/workflows.ts index cdd64156e6..228297dde7 100644 --- a/apps/web/playwright/fixtures/workflows.ts +++ b/apps/web/playwright/fixtures/workflows.ts @@ -4,7 +4,7 @@ import { expect, type Page } from "@playwright/test"; import prisma from "@calcom/prisma"; import { WorkflowTriggerEvents } from "@calcom/prisma/enums"; -import { localize } from "../lib/testUtils"; +import { localize } from "../lib/localize"; type CreateWorkflowProps = { name?: string; diff --git a/apps/web/playwright/lib/localize.ts b/apps/web/playwright/lib/localize.ts new file mode 100644 index 0000000000..2afc3d46d3 --- /dev/null +++ b/apps/web/playwright/lib/localize.ts @@ -0,0 +1,11 @@ +import { loadJSON } from "./loadJSON"; + +// Provide an standalone localize utility not managed by next-i18n +export async function localize(locale: string) { + const localeModule = `../../public/static/locales/${locale}/common.json`; + const localeMap = loadJSON(localeModule); + return (message: string) => { + if (message in localeMap) return localeMap[message]; + throw "No locale found for the given entry message"; + }; +} diff --git a/apps/web/playwright/lib/testUtils.ts b/apps/web/playwright/lib/testUtils.ts index 257507345c..84762de8c4 100644 --- a/apps/web/playwright/lib/testUtils.ts +++ b/apps/web/playwright/lib/testUtils.ts @@ -14,7 +14,6 @@ import { BookingStatus, SchedulingType } from "@calcom/prisma/enums"; import type { createEmailsFixture } from "../fixtures/emails"; import type { Fixtures } from "./fixtures"; -import { loadJSON } from "./loadJSON"; type Request = IncomingMessage & { body?: unknown }; type RequestHandlerOptions = { req: Request; res: ServerResponse }; @@ -178,16 +177,6 @@ export async function expectSlotNotAllowedToBook(page: Page) { await expect(page.locator("[data-testid=slot-not-allowed-to-book]")).toBeVisible(); } -// Provide an standalone localize utility not managed by next-i18n -export async function localize(locale: string) { - const localeModule = `../../public/static/locales/${locale}/common.json`; - const localeMap = loadJSON(localeModule); - return (message: string) => { - if (message in localeMap) return localeMap[message]; - throw "No locale found for the given entry message"; - }; -} - export const createNewEventType = async (page: Page, args: { eventTitle: string }) => { await page.click("[data-testid=new-event-type]"); const eventTitle = args.eventTitle; diff --git a/apps/web/playwright/login.e2e.ts b/apps/web/playwright/login.e2e.ts index 9f089080c7..3a898e5629 100644 --- a/apps/web/playwright/login.e2e.ts +++ b/apps/web/playwright/login.e2e.ts @@ -2,7 +2,7 @@ import { expect } from "@playwright/test"; import { login } from "./fixtures/users"; import { test } from "./lib/fixtures"; -import { localize } from "./lib/testUtils"; +import { localize } from "./lib/localize"; test.describe.configure({ mode: "parallel" }); diff --git a/apps/web/playwright/managed-event-types.e2e.ts b/apps/web/playwright/managed-event-types.e2e.ts index 93276ce49c..b14d4718cf 100644 --- a/apps/web/playwright/managed-event-types.e2e.ts +++ b/apps/web/playwright/managed-event-types.e2e.ts @@ -2,9 +2,9 @@ import type { Locator, Page } from "@playwright/test"; import { expect } from "@playwright/test"; import { test } from "./lib/fixtures"; +import { localize } from "./lib/localize"; import { bookTimeSlot, - localize, submitAndWaitForResponse, selectFirstAvailableTimeSlotNextMonth, setupManagedEvent, diff --git a/apps/web/playwright/out-of-office.e2e.ts b/apps/web/playwright/out-of-office.e2e.ts index 94ab0b575c..1e6cc250d3 100644 --- a/apps/web/playwright/out-of-office.e2e.ts +++ b/apps/web/playwright/out-of-office.e2e.ts @@ -8,7 +8,8 @@ import prisma from "@calcom/prisma"; import { MembershipRole } from "@calcom/prisma/enums"; import { test } from "./lib/fixtures"; -import { submitAndWaitForResponse, localize } from "./lib/testUtils"; +import { localize } from "./lib/localize"; +import { submitAndWaitForResponse } from "./lib/testUtils"; test.describe.configure({ mode: "parallel" }); test.afterEach(async ({ users }) => { diff --git a/apps/web/playwright/signup.e2e.ts b/apps/web/playwright/signup.e2e.ts index 61ddd70226..189ad760ef 100644 --- a/apps/web/playwright/signup.e2e.ts +++ b/apps/web/playwright/signup.e2e.ts @@ -6,7 +6,8 @@ import { APP_NAME, IS_PREMIUM_USERNAME_ENABLED, IS_MAILHOG_ENABLED } from "@calc import prisma from "@calcom/prisma"; import { test } from "./lib/fixtures"; -import { getEmailsReceivedByUser, localize } from "./lib/testUtils"; +import { localize } from "./lib/localize"; +import { getEmailsReceivedByUser } from "./lib/testUtils"; import { expectInvitationEmailToBeReceived } from "./team/expects"; test.describe.configure({ mode: "parallel" }); diff --git a/apps/web/playwright/team/team-invitation.e2e.ts b/apps/web/playwright/team/team-invitation.e2e.ts index 2b18d0b6db..f32d580e32 100644 --- a/apps/web/playwright/team/team-invitation.e2e.ts +++ b/apps/web/playwright/team/team-invitation.e2e.ts @@ -5,7 +5,8 @@ import { prisma } from "@calcom/prisma"; import { MembershipRole, SchedulingType } from "@calcom/prisma/enums"; import { test } from "../lib/fixtures"; -import { getInviteLink, localize } from "../lib/testUtils"; +import { localize } from "../lib/localize"; +import { getInviteLink } from "../lib/testUtils"; import { expectInvitationEmailToBeReceived } from "./expects"; test.describe.configure({ mode: "parallel" }); diff --git a/packages/features/bookings/lib/getBookingToDelete.ts b/packages/features/bookings/lib/getBookingToDelete.ts new file mode 100644 index 0000000000..b6b9ae31c1 --- /dev/null +++ b/packages/features/bookings/lib/getBookingToDelete.ts @@ -0,0 +1,104 @@ +import { workflowSelect } from "@calcom/features/ee/workflows/lib/getAllWorkflows"; +import prisma, { bookingMinimalSelect } from "@calcom/prisma"; +import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; + +export async function getBookingToDelete(id: number | undefined, uid: string | undefined) { + return await prisma.booking.findUniqueOrThrow({ + where: { + id, + uid, + }, + select: { + ...bookingMinimalSelect, + recurringEventId: true, + userId: true, + user: { + select: { + id: true, + username: true, + credentials: { select: credentialForCalendarServiceSelect }, // Not leaking at the moment, be careful with + email: true, + timeZone: true, + timeFormat: true, + name: true, + destinationCalendar: true, + }, + }, + location: true, + references: { + select: { + uid: true, + type: true, + externalCalendarId: true, + credentialId: true, + thirdPartyRecurringEventId: true, + delegationCredentialId: true, + }, + }, + payment: true, + paid: true, + eventType: { + select: { + slug: true, + owner: { + select: { + id: true, + hideBranding: true, + }, + }, + team: { + select: { + id: true, + name: true, + parentId: true, + }, + }, + parentId: true, + parent: { + select: { + teamId: true, + }, + }, + userId: true, + recurringEvent: true, + title: true, + eventName: true, + description: true, + requiresConfirmation: true, + price: true, + currency: true, + length: true, + seatsPerTimeSlot: true, + bookingFields: true, + seatsShowAttendees: true, + metadata: true, + schedulingType: true, + hosts: { + select: { + user: true, + }, + }, + workflows: { + select: { + workflow: { + select: workflowSelect, + }, + }, + }, + }, + }, + uid: true, + id: true, + eventTypeId: true, + destinationCalendar: true, + smsReminderNumber: true, + workflowReminders: true, + seatsReferences: true, + responses: true, + iCalUID: true, + iCalSequence: true, + }, + }); +} + +export type BookingToDelete = Awaited>; diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.ts index 2703c35ec0..ac5c6d1230 100644 --- a/packages/features/bookings/lib/handleCancelBooking.ts +++ b/packages/features/bookings/lib/handleCancelBooking.ts @@ -6,7 +6,6 @@ import { DailyLocationType } from "@calcom/app-store/locations"; import dayjs from "@calcom/dayjs"; import { sendCancelledEmailsAndSMS } from "@calcom/emails"; import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses"; -import { workflowSelect } from "@calcom/features/ee/workflows/lib/getAllWorkflows"; import { sendCancelledReminders } from "@calcom/features/ee/workflows/lib/reminders/reminderScheduler"; import type { GetSubscriberOptions } from "@calcom/features/webhooks/lib/getWebhooks"; import getWebhooks from "@calcom/features/webhooks/lib/getWebhooks"; @@ -25,133 +24,22 @@ import { safeStringify } from "@calcom/lib/safeStringify"; import { getTranslation } from "@calcom/lib/server/i18n"; import { WorkflowRepository } from "@calcom/lib/server/repository/workflow"; import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat"; -import prisma, { bookingMinimalSelect } from "@calcom/prisma"; +import prisma from "@calcom/prisma"; import type { WebhookTriggerEvents } from "@calcom/prisma/enums"; import { BookingStatus } from "@calcom/prisma/enums"; -import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential"; import { bookingMetadataSchema, EventTypeMetaDataSchema, bookingCancelInput } from "@calcom/prisma/zod-utils"; import type { EventTypeMetadata } from "@calcom/prisma/zod-utils"; import { getAllWorkflowsFromEventType } from "@calcom/trpc/server/routers/viewer/workflows/util"; import type { CalendarEvent } from "@calcom/types/Calendar"; import { getAllCredentials } from "./getAllCredentialsForUsersOnEvent/getAllCredentials"; +import { getBookingToDelete } from "./getBookingToDelete"; +import type { CustomRequest, AppRouterRequest } from "./handleCancelBooking/types"; import { handleInternalNote } from "./handleInternalNote"; import cancelAttendeeSeat from "./handleSeats/cancel/cancelAttendeeSeat"; const log = logger.getSubLogger({ prefix: ["handleCancelBooking"] }); -async function getBookingToDelete(id: number | undefined, uid: string | undefined) { - return await prisma.booking.findUniqueOrThrow({ - where: { - id, - uid, - }, - select: { - ...bookingMinimalSelect, - recurringEventId: true, - userId: true, - user: { - select: { - id: true, - username: true, - credentials: { select: credentialForCalendarServiceSelect }, // Not leaking at the moment, be careful with - email: true, - timeZone: true, - timeFormat: true, - name: true, - destinationCalendar: true, - }, - }, - location: true, - references: { - select: { - uid: true, - type: true, - externalCalendarId: true, - credentialId: true, - thirdPartyRecurringEventId: true, - delegationCredentialId: true, - }, - }, - payment: true, - paid: true, - eventType: { - select: { - slug: true, - owner: { - select: { - id: true, - hideBranding: true, - }, - }, - team: { - select: { - id: true, - name: true, - parentId: true, - }, - }, - parentId: true, - parent: { - select: { - teamId: true, - }, - }, - userId: true, - recurringEvent: true, - title: true, - eventName: true, - description: true, - requiresConfirmation: true, - price: true, - currency: true, - length: true, - seatsPerTimeSlot: true, - bookingFields: true, - seatsShowAttendees: true, - metadata: true, - schedulingType: true, - hosts: { - select: { - user: true, - }, - }, - workflows: { - select: { - workflow: { - select: workflowSelect, - }, - }, - }, - }, - }, - uid: true, - id: true, - eventTypeId: true, - destinationCalendar: true, - smsReminderNumber: true, - workflowReminders: true, - seatsReferences: true, - responses: true, - iCalUID: true, - iCalSequence: true, - }, - }); -} - -export type BookingToDelete = Awaited>; - -export type AppRouterRequest = { appDirRequestBody: unknown }; -export type CustomRequest = (NextApiRequest | AppRouterRequest) & { - userId?: number; - bookingToDelete?: BookingToDelete; - platformClientId?: string; - platformRescheduleUrl?: string; - platformCancelUrl?: string; - platformBookingUrl?: string; - arePlatformEmailsEnabled?: boolean; -}; - export type HandleCancelBookingResponse = { success: boolean; message: string; diff --git a/packages/features/bookings/lib/handleCancelBooking/types.ts b/packages/features/bookings/lib/handleCancelBooking/types.ts new file mode 100644 index 0000000000..4b82de8c3c --- /dev/null +++ b/packages/features/bookings/lib/handleCancelBooking/types.ts @@ -0,0 +1,14 @@ +import type { NextApiRequest } from "next"; + +import type { BookingToDelete } from "../getBookingToDelete"; + +export type AppRouterRequest = { appDirRequestBody: unknown }; +export type CustomRequest = (NextApiRequest | AppRouterRequest) & { + userId?: number; + bookingToDelete?: BookingToDelete; + platformClientId?: string; + platformRescheduleUrl?: string; + platformCancelUrl?: string; + platformBookingUrl?: string; + arePlatformEmailsEnabled?: boolean; +}; diff --git a/packages/features/bookings/lib/handleInternalNote.ts b/packages/features/bookings/lib/handleInternalNote.ts index 0471ec1648..33ed3efe70 100644 --- a/packages/features/bookings/lib/handleInternalNote.ts +++ b/packages/features/bookings/lib/handleInternalNote.ts @@ -1,7 +1,7 @@ import { HttpError } from "@calcom/lib/http-error"; import prisma from "@calcom/prisma"; -import { type BookingToDelete } from "./handleCancelBooking"; +import type { BookingToDelete } from "./getBookingToDelete"; type InternalNote = { id: number; diff --git a/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts b/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts index d446e6a0ba..d769c39a47 100644 --- a/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts +++ b/packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts @@ -18,7 +18,7 @@ import { bookingCancelAttendeeSeatSchema } from "@calcom/prisma/zod-utils"; import type { EventTypeMetadata } from "@calcom/prisma/zod-utils"; import type { CalendarEvent } from "@calcom/types/Calendar"; -import type { AppRouterRequest, CustomRequest } from "../../handleCancelBooking"; +import type { AppRouterRequest, CustomRequest } from "../../handleCancelBooking/types"; async function cancelAttendeeSeat( req: CustomRequest, diff --git a/packages/features/ee/teams/components/DeleteBulkTeamMembers.tsx b/packages/features/ee/teams/components/DeleteBulkTeamMembers.tsx index ae284448b9..9db7eb315e 100644 --- a/packages/features/ee/teams/components/DeleteBulkTeamMembers.tsx +++ b/packages/features/ee/teams/components/DeleteBulkTeamMembers.tsx @@ -1,10 +1,11 @@ import { DataTableSelectionBar } from "@calcom/features/data-table"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; +import type { RouterOutputs } from "@calcom/trpc/react"; import { Dialog, DialogTrigger, ConfirmationDialogContent } from "@calcom/ui/components/dialog"; import { showToast } from "@calcom/ui/components/toast"; -import type { User } from "./MemberList"; +export type User = RouterOutputs["viewer"]["teams"]["listMembers"]["members"][number]; interface Props { users: User[];