feat: use the correct locale for the title (#9286)
This commit is contained in:
parent
1e857e5c0a
commit
c958e1578a
|
@ -178,7 +178,10 @@ export const sendDeclinedEmails = async (calEvent: CalendarEvent) => {
|
|||
await Promise.all(emailsToSend);
|
||||
};
|
||||
|
||||
export const sendCancelledEmails = async (calEvent: CalendarEvent) => {
|
||||
export const sendCancelledEmails = async (
|
||||
calEvent: CalendarEvent,
|
||||
eventNameObject: Pick<EventNameObjectType, "eventName">
|
||||
) => {
|
||||
const emailsToSend: Promise<unknown>[] = [];
|
||||
|
||||
emailsToSend.push(sendEmail(() => new OrganizerCancelledEmail({ calEvent })));
|
||||
|
@ -191,7 +194,24 @@ export const sendCancelledEmails = async (calEvent: CalendarEvent) => {
|
|||
|
||||
emailsToSend.push(
|
||||
...calEvent.attendees.map((attendee) => {
|
||||
return sendEmail(() => new AttendeeCancelledEmail(calEvent, attendee));
|
||||
return sendEmail(
|
||||
() =>
|
||||
new AttendeeCancelledEmail(
|
||||
{
|
||||
...calEvent,
|
||||
title: getEventName({
|
||||
...eventNameObject,
|
||||
t: attendee.language.translate,
|
||||
attendeeName: attendee.name,
|
||||
host: calEvent.organizer.name,
|
||||
eventType: calEvent.type,
|
||||
...(calEvent.responses && { bookingFields: calEvent.responses }),
|
||||
...(calEvent.location && { location: calEvent.location }),
|
||||
}),
|
||||
},
|
||||
attendee
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ async function getBookingToDelete(id: number | undefined, uid: string | undefine
|
|||
teamId: true,
|
||||
recurringEvent: true,
|
||||
title: true,
|
||||
eventName: true,
|
||||
description: true,
|
||||
requiresConfirmation: true,
|
||||
price: true,
|
||||
|
@ -656,7 +657,7 @@ async function handler(req: CustomRequest) {
|
|||
|
||||
await Promise.all(prismaPromises.concat(apiDeletes));
|
||||
|
||||
await sendCancelledEmails(evt);
|
||||
await sendCancelledEmails(evt, { eventName: bookingToDelete?.eventType?.eventName });
|
||||
|
||||
req.statusCode = 200;
|
||||
return { message: "Booking successfully cancelled." };
|
||||
|
|
|
@ -215,6 +215,7 @@ export const deleteCredentialHandler = async ({ ctx, input }: DeleteCredentialOp
|
|||
bookingFields: true,
|
||||
seatsPerTimeSlot: true,
|
||||
seatsShowAttendees: true,
|
||||
eventName: true,
|
||||
},
|
||||
},
|
||||
uid: true,
|
||||
|
@ -273,32 +274,37 @@ export const deleteCredentialHandler = async ({ ctx, input }: DeleteCredentialOp
|
|||
|
||||
const attendeesList = await Promise.all(attendeesListPromises);
|
||||
const tOrganizer = await getTranslation(booking?.user?.locale ?? "en", "common");
|
||||
await sendCancelledEmails({
|
||||
type: booking?.eventType?.title as string,
|
||||
title: booking.title,
|
||||
description: booking.description,
|
||||
customInputs: isPrismaObjOrUndefined(booking.customInputs),
|
||||
...getCalEventResponses({
|
||||
bookingFields: booking.eventType?.bookingFields ?? null,
|
||||
booking,
|
||||
}),
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
organizer: {
|
||||
email: booking?.user?.email as string,
|
||||
name: booking?.user?.name ?? "Nameless",
|
||||
timeZone: booking?.user?.timeZone as string,
|
||||
language: { translate: tOrganizer, locale: booking?.user?.locale ?? "en" },
|
||||
await sendCancelledEmails(
|
||||
{
|
||||
type: booking?.eventType?.title as string,
|
||||
title: booking.title,
|
||||
description: booking.description,
|
||||
customInputs: isPrismaObjOrUndefined(booking.customInputs),
|
||||
...getCalEventResponses({
|
||||
bookingFields: booking.eventType?.bookingFields ?? null,
|
||||
booking,
|
||||
}),
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
organizer: {
|
||||
email: booking?.user?.email as string,
|
||||
name: booking?.user?.name ?? "Nameless",
|
||||
timeZone: booking?.user?.timeZone as string,
|
||||
language: { translate: tOrganizer, locale: booking?.user?.locale ?? "en" },
|
||||
},
|
||||
attendees: attendeesList,
|
||||
uid: booking.uid,
|
||||
recurringEvent: parseRecurringEvent(booking.eventType?.recurringEvent),
|
||||
location: booking.location,
|
||||
destinationCalendar: booking.destinationCalendar || booking.user?.destinationCalendar,
|
||||
cancellationReason: "Payment method removed by organizer",
|
||||
seatsPerTimeSlot: booking.eventType?.seatsPerTimeSlot,
|
||||
seatsShowAttendees: booking.eventType?.seatsShowAttendees,
|
||||
},
|
||||
attendees: attendeesList,
|
||||
uid: booking.uid,
|
||||
recurringEvent: parseRecurringEvent(booking.eventType?.recurringEvent),
|
||||
location: booking.location,
|
||||
destinationCalendar: booking.destinationCalendar || booking.user?.destinationCalendar,
|
||||
cancellationReason: "Payment method removed by organizer",
|
||||
seatsPerTimeSlot: booking.eventType?.seatsPerTimeSlot,
|
||||
seatsShowAttendees: booking.eventType?.seatsShowAttendees,
|
||||
});
|
||||
{
|
||||
eventName: booking?.eventType?.eventName,
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user