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 AttendeeRequestEmail extends AttendeeScheduledEmail { protected getNodeMailerPayload(): Record { const toAddresses = [this.calEvent.attendees[0].email]; if (this.calEvent.team) { this.calEvent.team.members.forEach((member) => { const memberAttendee = this.calEvent.attendees.find((attendee) => attendee.name === member); if (memberAttendee) { toAddresses.push(memberAttendee.email); } }); } return { from: `Cal.com <${this.getMailerOptions().from}>`, to: toAddresses.join(","), subject: `${this.calEvent.organizer.language.translate("booking_submitted_subject", { eventType: this.calEvent.type, name: this.calEvent.attendees[0].name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" )}, ${this.calEvent.organizer.language.translate( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.calEvent.organizer.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.calEvent.attendees[0].language.translate("booking_submitted", { name: this.calEvent.attendees[0].name, })} ${this.calEvent.attendees[0].language.translate("user_needs_to_confirm_or_reject_booking", { user: this.calEvent.organizer.name, })} ${this.getWhat()} ${this.getWhen()} ${this.getLocation()} ${this.getDescription()} ${this.getAdditionalNotes()} `.replace(/(<([^>]+)>)/gi, ""); } protected getHtmlBody(): string { const headerContent = this.calEvent.attendees[0].language.translate("booking_submitted_subject", { eventType: this.calEvent.type, name: this.calEvent.attendees[0].name, date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format( "h:mma" )}, ${this.calEvent.attendees[0].language.translate( this.getInviteeStart().format("dddd").toLowerCase() )}, ${this.calEvent.attendees[0].language.translate( this.getInviteeStart().format("MMMM").toLowerCase() )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`, }); return ` ${emailHead(headerContent)}
${emailSchedulingBodyHeader("calendarCircle")} ${emailScheduledBodyHeaderContent( this.calEvent.organizer.language.translate("booking_submitted"), this.calEvent.organizer.language.translate("user_needs_to_confirm_or_reject_booking", { user: this.calEvent.organizer.name, }) )} ${emailSchedulingBodyDivider()}
${this.getWhat()} ${this.getWhen()} ${this.getWho()} ${this.getLocation()} ${this.getDescription()} ${this.getAdditionalNotes()}
${emailSchedulingBodyDivider()} ${emailBodyLogo()}
`; } }