import dayjs from "dayjs"; import localizedFormat from "dayjs/plugin/localizedFormat"; import timezone from "dayjs/plugin/timezone"; import toArray from "dayjs/plugin/toArray"; import utc from "dayjs/plugin/utc"; import AttendeeScheduledEmail from "./attendee-scheduled-email"; import { emailHead, emailSchedulingBodyHeader, emailBodyLogo, emailScheduledBodyHeaderContent, emailSchedulingBodyDivider, linkIcon, } from "./common"; dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(localizedFormat); dayjs.extend(toArray); export default class AttendeeAwaitingPaymentEmail extends AttendeeScheduledEmail { protected getNodeMailerPayload(): Record { return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, replyTo: this.calEvent.organizer.email, subject: `${this.calEvent.language("awaiting_payment_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" )}, ${this.calEvent.language( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.calEvent.language( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, })}`, html: this.getHtmlBody(), text: this.getTextBody(), }; } protected getTextBody(): string { return ` ${this.calEvent.language("meeting_awaiting_payment")} ${this.calEvent.language("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} ${this.getAdditionalNotes()} `.replace(/(<([^>]+)>)/gi, ""); } protected getHtmlBody(): string { const headerContent = this.calEvent.language("awaiting_payment_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" )}, ${this.calEvent.language( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.calEvent.language( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); return ` ${emailHead(headerContent)}
${emailSchedulingBodyHeader("calendarCircle")} ${emailScheduledBodyHeaderContent( this.calEvent.language("meeting_awaiting_payment"), this.calEvent.language("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()}
${this.getWhat()} ${this.getWhen()} ${this.getWho()} ${this.getLocation()} ${this.getAdditionalNotes()}
${emailSchedulingBodyDivider()}
${this.getManageLink()}
${emailBodyLogo()}
`; } protected getManageLink(): string { const manageText = this.calEvent.language("pay_now"); if (this.calEvent.paymentInfo) { return `

${manageText}

`; } return ""; } }