Scheduling infrastructure for absolutely everyone.
fix: use correct organizer info when admin accepts team booking requiring confirmation (#20612)
Anik Dhabal Babu3d02df3b08ff
diff --git a/apps/web/playwright/webhook.e2e.ts b/apps/web/playwright/webhook.e2e.tsindex 3ae55398a05..2edb7d13268 100644--- a/apps/web/playwright/webhook.e2e.ts+++ b/apps/web/playwright/webhook.e2e.ts@@ -191,7 +191,7 @@ test.describe("BOOKING_REJECTED", async () => {endTime: "[redacted/dynamic]",organizer: {id: "[redacted/dynamic]",- name: "Unnamed",+ name: "Nameless",email: "[redacted/dynamic]",timeZone: "[redacted/dynamic]",language: "[redacted/dynamic]",diff --git a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts b/packages/trpc/server/routers/viewer/bookings/confirm.handler.tsindex 1289185fa1c..1bce9327498 100644--- a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts+++ b/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts@@ -51,8 +51,6 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {platformClientParams,} = input;- const tOrganizer = await getTranslation(user.locale ?? "en", "common");-const booking = await prisma.booking.findUniqueOrThrow({where: {id: bookingId,@@ -110,6 +108,18 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {},location: true,userId: true,+ user: {+ select: {+ id: true,+ username: true,+ email: true,+ timeZone: true,+ timeFormat: true,+ name: true,+ destinationCalendar: true,+ locale: true,+ },+ },id: true,uid: true,payment: true,@@ -183,6 +193,7 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {);const attendeesList = await Promise.all(attendeesListPromises);+ const tOrganizer = await getTranslation(booking.user?.locale ?? "en", "common");const evt: CalendarEvent = {type: booking?.eventType?.slug as string,@@ -198,20 +209,20 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {startTime: booking.startTime.toISOString(),endTime: booking.endTime.toISOString(),organizer: {- email: booking.userPrimaryEmail ?? user.email,- name: user.name || "Unnamed",- username: user.username || undefined,- timeZone: user.timeZone,- timeFormat: getTimeFormatStringFromUserTimeFormat(user.timeFormat),- language: { translate: tOrganizer, locale: user.locale ?? "en" },+ email: booking?.userPrimaryEmail || booking.user?.email || "Email-less",+ name: booking.user?.name || "Nameless",+ username: booking.user?.username || undefined,+ timeZone: booking.user?.timeZone || "Europe/London",+ timeFormat: getTimeFormatStringFromUserTimeFormat(booking.user?.timeFormat),+ language: { translate: tOrganizer, locale: booking.user?.locale ?? "en" },},attendees: attendeesList,location: booking.location ?? "",uid: booking.uid,- destinationCalendar: booking?.destinationCalendar+ destinationCalendar: booking.destinationCalendar? [booking.destinationCalendar]- : user.destinationCalendar- ? [user.destinationCalendar]+ : booking.user?.destinationCalendar+ ? [booking.user?.destinationCalendar]: [],requiresConfirmation: booking?.eventType?.requiresConfirmation ?? false,eventTypeId: booking.eventType?.id,