From 8f3f17b2997ea67f1417be64e15ca4b71a736917 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung Date: Tue, 21 Feb 2023 13:52:39 -0500 Subject: [PATCH] Change organizer scheduled input to an object --- packages/emails/email-manager.ts | 40 +++++++++---------- .../templates/organizer-scheduled-email.ts | 8 ++-- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/packages/emails/email-manager.ts b/packages/emails/email-manager.ts index 8615d8ac4c..6f14912a30 100644 --- a/packages/emails/email-manager.ts +++ b/packages/emails/email-manager.ts @@ -48,7 +48,7 @@ export const sendScheduledEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerScheduledEmail(clonedEvent); + const scheduledEmail = new OrganizerScheduledEmail({ calEvent: clonedEvent }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerScheduledEmail.sendEmail failed", e)); @@ -61,7 +61,7 @@ export const sendScheduledEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerScheduledEmail(clonedEvent, undefined, teamMember); + const scheduledEmail = new OrganizerScheduledEmail({ calEvent: clonedEvent, teamMember }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerScheduledEmail.sendEmail failed", e)); @@ -96,7 +96,7 @@ export const sendRescheduledEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerRescheduledEmail(clonedEvent); + const scheduledEmail = new OrganizerRescheduledEmail({ calEvent: clonedEvent }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerRescheduledEmail.sendEmail failed", e)); @@ -109,7 +109,7 @@ export const sendRescheduledEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerRescheduledEmail(clonedEvent, undefined, teamMember); + const scheduledEmail = new OrganizerRescheduledEmail({ calEvent: clonedEvent, teamMember }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerRescheduledEmail.sendEmail failed", e)); @@ -144,7 +144,7 @@ export const sendScheduledSeatsEmails = async ( emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerScheduledEmail(calEvent, newSeat); + const scheduledEmail = new OrganizerScheduledEmail({ calEvent, newSeat }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerScheduledEmail.sendEmail failed", e)); @@ -161,7 +161,7 @@ export const sendOrganizerRequestEmail = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const organizerRequestEmail = new OrganizerRequestEmail(calEvent); + const organizerRequestEmail = new OrganizerRequestEmail({ calEvent }); resolve(organizerRequestEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerRequestEmail.sendEmail failed", e)); @@ -174,7 +174,7 @@ export const sendOrganizerRequestEmail = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const organizerRequestEmail = new OrganizerRequestEmail(calEvent, undefined, teamMember); + const organizerRequestEmail = new OrganizerRequestEmail({ calEvent, teamMember }); resolve(organizerRequestEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerRequestEmail.sendEmail failed", e)); @@ -238,7 +238,7 @@ export const sendCancelledEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerCancelledEmail(clonedEvent); + const scheduledEmail = new OrganizerCancelledEmail({ calEvent: clonedEvent }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerCancelledEmail.sendEmail failed", e)); @@ -251,7 +251,7 @@ export const sendCancelledEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerCancelledEmail(clonedEvent, undefined, teamMember); + const scheduledEmail = new OrganizerCancelledEmail({ calEvent: clonedEvent, teamMember }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerCancelledEmail.sendEmail failed", e)); @@ -270,7 +270,7 @@ export const sendOrganizerRequestReminderEmail = async (calEvent: CalendarEvent) emailsToSend.push( new Promise((resolve, reject) => { try { - const organizerRequestReminderEmail = new OrganizerRequestReminderEmail(calEvent); + const organizerRequestReminderEmail = new OrganizerRequestReminderEmail({ calEvent }); resolve(organizerRequestReminderEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerRequestReminderEmail.sendEmail failed", e)); @@ -283,11 +283,10 @@ export const sendOrganizerRequestReminderEmail = async (calEvent: CalendarEvent) emailsToSend.push( new Promise((resolve, reject) => { try { - const organizerRequestReminderEmail = new OrganizerRequestReminderEmail( + const organizerRequestReminderEmail = new OrganizerRequestReminderEmail({ calEvent, - undefined, - teamMember - ); + teamMember, + }); resolve(organizerRequestReminderEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerRequestReminderEmail.sendEmail failed", e)); @@ -321,7 +320,7 @@ export const sendOrganizerPaymentRefundFailedEmail = async (calEvent: CalendarEv emailsToSend.push( new Promise((resolve, reject) => { try { - const paymentRefundFailedEmail = new OrganizerPaymentRefundFailedEmail(calEvent); + const paymentRefundFailedEmail = new OrganizerPaymentRefundFailedEmail({ calEvent }); resolve(paymentRefundFailedEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerPaymentRefundFailedEmail.sendEmail failed", e)); @@ -334,11 +333,10 @@ export const sendOrganizerPaymentRefundFailedEmail = async (calEvent: CalendarEv emailsToSend.push( new Promise((resolve, reject) => { try { - const paymentRefundFailedEmail = new OrganizerPaymentRefundFailedEmail( + const paymentRefundFailedEmail = new OrganizerPaymentRefundFailedEmail({ calEvent, - undefined, - teamMember - ); + teamMember, + }); resolve(paymentRefundFailedEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerPaymentRefundFailedEmail.sendEmail failed", e)); @@ -425,7 +423,7 @@ export const sendLocationChangeEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerLocationChangeEmail(clonedEvent); + const scheduledEmail = new OrganizerLocationChangeEmail({ calEvent: clonedEvent }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerLocationChangeEmail.sendEmail failed", e)); @@ -438,7 +436,7 @@ export const sendLocationChangeEmails = async (calEvent: CalendarEvent) => { emailsToSend.push( new Promise((resolve, reject) => { try { - const scheduledEmail = new OrganizerLocationChangeEmail(clonedEvent, undefined, teamMember); + const scheduledEmail = new OrganizerLocationChangeEmail({ calEvent: clonedEvent, teamMember }); resolve(scheduledEmail.sendEmail()); } catch (e) { reject(console.error("OrganizerLocationChangeEmail.sendEmail failed", e)); diff --git a/packages/emails/templates/organizer-scheduled-email.ts b/packages/emails/templates/organizer-scheduled-email.ts index 1c5af677a8..dbd91140f7 100644 --- a/packages/emails/templates/organizer-scheduled-email.ts +++ b/packages/emails/templates/organizer-scheduled-email.ts @@ -17,13 +17,13 @@ export default class OrganizerScheduledEmail extends BaseEmail { newSeat?: boolean; teamMember?: Person; - constructor(calEvent: CalendarEvent, newSeat?: boolean, teamMember?: Person) { + constructor(input: { calEvent: CalendarEvent; newSeat?: boolean; teamMember?: Person }) { super(); this.name = "SEND_BOOKING_CONFIRMATION"; - this.calEvent = calEvent; + this.calEvent = input.calEvent; this.t = this.calEvent.organizer.language.translate; - this.newSeat = newSeat; - this.teamMember = teamMember; + this.newSeat = input.newSeat; + this.teamMember = input.teamMember; } protected getiCalEventAsString(): string | undefined {