fix: use correct organizer info when admin accepts team booking requiring confirmation (#20612)

* fix: confrim handler

* fix test
This commit is contained in:
Anik Dhabal Babu authored and GitHub committed 2025-04-09 10:45:27 +05:30
1 parent b9b12256fa
commit 3d02df3b08
2 files changed
+23 -12

No files matched your search

+1 -1
View File
@@ -191,7 +191,7 @@ test.describe("BOOKING_REJECTED", async () => {
endTime: "[redacted/dynamic]", endTime: "[redacted/dynamic]",
organizer: { organizer: {
id: "[redacted/dynamic]", id: "[redacted/dynamic]",
name: "Unnamed", name: "Nameless",
email: "[redacted/dynamic]", email: "[redacted/dynamic]",
timeZone: "[redacted/dynamic]", timeZone: "[redacted/dynamic]",
language: "[redacted/dynamic]", language: "[redacted/dynamic]",
@@ -51,8 +51,6 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
platformClientParams, platformClientParams,
} = input; } = input;
const tOrganizer = await getTranslation(user.locale ?? "en", "common");
const booking = await prisma.booking.findUniqueOrThrow({ const booking = await prisma.booking.findUniqueOrThrow({
where: { where: {
id: bookingId, id: bookingId,
@@ -110,6 +108,18 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
}, },
location: true, location: true,
userId: true, userId: true,
user: {
select: {
id: true,
username: true,
email: true,
timeZone: true,
timeFormat: true,
name: true,
destinationCalendar: true,
locale: true,
},
},
id: true, id: true,
uid: true, uid: true,
payment: true, payment: true,
@@ -183,6 +193,7 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
); );
const attendeesList = await Promise.all(attendeesListPromises); const attendeesList = await Promise.all(attendeesListPromises);
const tOrganizer = await getTranslation(booking.user?.locale ?? "en", "common");
const evt: CalendarEvent = { const evt: CalendarEvent = {
type: booking?.eventType?.slug as string, type: booking?.eventType?.slug as string,
@@ -198,20 +209,20 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
startTime: booking.startTime.toISOString(), startTime: booking.startTime.toISOString(),
endTime: booking.endTime.toISOString(), endTime: booking.endTime.toISOString(),
organizer: { organizer: {
email: booking.userPrimaryEmail ?? user.email, email: booking?.userPrimaryEmail || booking.user?.email || "Email-less",
name: user.name || "Unnamed", name: booking.user?.name || "Nameless",
username: user.username || undefined, username: booking.user?.username || undefined,
timeZone: user.timeZone, timeZone: booking.user?.timeZone || "Europe/London",
timeFormat: getTimeFormatStringFromUserTimeFormat(user.timeFormat), timeFormat: getTimeFormatStringFromUserTimeFormat(booking.user?.timeFormat),
language: { translate: tOrganizer, locale: user.locale ?? "en" }, language: { translate: tOrganizer, locale: booking.user?.locale ?? "en" },
}, },
attendees: attendeesList, attendees: attendeesList,
location: booking.location ?? "", location: booking.location ?? "",
uid: booking.uid, uid: booking.uid,
destinationCalendar: booking?.destinationCalendar destinationCalendar: booking.destinationCalendar
? [booking.destinationCalendar] ? [booking.destinationCalendar]
: user.destinationCalendar : booking.user?.destinationCalendar
? [user.destinationCalendar] ? [booking.user?.destinationCalendar]
: [], : [],
requiresConfirmation: booking?.eventType?.requiresConfirmation ?? false, requiresConfirmation: booking?.eventType?.requiresConfirmation ?? false,
eventTypeId: booking.eventType?.id, eventTypeId: booking.eventType?.id,