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, } from "./common"; dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(localizedFormat); dayjs.extend(toArray); export default class AttendeeCancelledEmail 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.attendee.language.translate("event_cancelled_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.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, })}`, html: this.getHtmlBody(), text: this.getTextBody(), }; } protected getTextBody(): string { return ` ${this.attendee.language.translate("event_request_cancelled")} ${this.attendee.language.translate("emailed_you_and_any_other_attendees")} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} ${this.getAdditionalNotes()} ${this.calEvent.cancellationReason && this.getCancellationReason()} `.replace(/(<([^>]+)>)/gi, ""); } protected getHtmlBody(): string { const headerContent = this.attendee.language.translate("event_cancelled_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.attendee.language.translate( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.attendee.language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); return ` ${emailHead(headerContent)}
${emailSchedulingBodyHeader("xCircle")} ${emailScheduledBodyHeaderContent( this.attendee.language.translate("event_request_cancelled"), this.attendee.language.translate("emailed_you_and_any_other_attendees") )} ${emailSchedulingBodyDivider()}
${this.getWhat()} ${this.getWhen()} ${this.getWho()} ${this.getLocation()} ${this.getAdditionalNotes()} ${this.calEvent.cancellationReason && this.getCancellationReason()}
${emailBodyLogo()}
`; } protected getCancellationReason(): string { return `

${this.attendee.language.translate("cancellation_reason")}

${this.calEvent.cancellationReason}

`; } }