2021-11-26 11:03:43 +00:00
|
|
|
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";
|
|
|
|
|
2021-12-01 10:32:08 +00:00
|
|
|
import {
|
|
|
|
emailHead,
|
|
|
|
emailSchedulingBodyHeader,
|
|
|
|
emailBodyLogo,
|
|
|
|
emailScheduledBodyHeaderContent,
|
|
|
|
emailSchedulingBodyDivider,
|
|
|
|
linkIcon,
|
|
|
|
} from "./common";
|
2021-11-26 11:03:43 +00:00
|
|
|
import OrganizerScheduledEmail from "./organizer-scheduled-email";
|
|
|
|
|
|
|
|
dayjs.extend(utc);
|
|
|
|
dayjs.extend(timezone);
|
|
|
|
dayjs.extend(localizedFormat);
|
|
|
|
dayjs.extend(toArray);
|
|
|
|
|
|
|
|
export default class OrganizerRequestReminderEmail extends OrganizerScheduledEmail {
|
|
|
|
protected getNodeMailerPayload(): Record<string, unknown> {
|
|
|
|
const toAddresses = [this.calEvent.organizer.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(","),
|
2022-01-27 20:32:53 +00:00
|
|
|
subject: `${this.calEvent.organizer.language.translate("event_awaiting_approval_subject", {
|
2021-11-26 11:03:43 +00:00
|
|
|
eventType: this.calEvent.type,
|
|
|
|
name: this.calEvent.attendees[0].name,
|
|
|
|
date: `${this.getOrganizerStart().format("h:mma")} - ${this.getOrganizerEnd().format(
|
|
|
|
"h:mma"
|
2022-01-27 20:32:53 +00:00
|
|
|
)}, ${this.calEvent.organizer.language.translate(
|
2021-11-26 11:03:43 +00:00
|
|
|
this.getOrganizerStart().format("dddd").toLowerCase()
|
2022-01-27 20:32:53 +00:00
|
|
|
)}, ${this.calEvent.organizer.language.translate(
|
2021-11-26 11:03:43 +00:00
|
|
|
this.getOrganizerStart().format("MMMM").toLowerCase()
|
|
|
|
)} ${this.getOrganizerStart().format("D")}, ${this.getOrganizerStart().format("YYYY")}`,
|
|
|
|
})}`,
|
|
|
|
html: this.getHtmlBody(),
|
|
|
|
text: this.getTextBody(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getTextBody(): string {
|
|
|
|
return `
|
2022-01-27 20:32:53 +00:00
|
|
|
${this.calEvent.organizer.language.translate("event_still_awaiting_approval")}
|
|
|
|
${this.calEvent.organizer.language.translate("someone_requested_an_event")}
|
2021-11-26 11:03:43 +00:00
|
|
|
${this.getWhat()}
|
|
|
|
${this.getWhen()}
|
|
|
|
${this.getLocation()}
|
|
|
|
${this.getAdditionalNotes()}
|
2022-01-27 20:32:53 +00:00
|
|
|
${this.calEvent.organizer.language.translate("confirm_or_reject_request")}
|
2022-03-26 00:39:38 +00:00
|
|
|
${process.env.NEXT_PUBLIC_WEBAPP_URL} + "/bookings/upcoming"
|
2021-11-26 11:03:43 +00:00
|
|
|
`.replace(/(<([^>]+)>)/gi, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getHtmlBody(): string {
|
2022-01-27 20:32:53 +00:00
|
|
|
const headerContent = this.calEvent.organizer.language.translate("event_awaiting_approval_subject", {
|
2021-11-26 11:03:43 +00:00
|
|
|
eventType: this.calEvent.type,
|
|
|
|
name: this.calEvent.attendees[0].name,
|
|
|
|
date: `${this.getOrganizerStart().format("h:mma")} - ${this.getOrganizerEnd().format(
|
|
|
|
"h:mma"
|
2022-01-27 20:32:53 +00:00
|
|
|
)}, ${this.calEvent.organizer.language.translate(
|
2021-11-26 11:03:43 +00:00
|
|
|
this.getOrganizerStart().format("dddd").toLowerCase()
|
2022-01-27 20:32:53 +00:00
|
|
|
)}, ${this.calEvent.organizer.language.translate(
|
2021-11-26 11:03:43 +00:00
|
|
|
this.getOrganizerStart().format("MMMM").toLowerCase()
|
|
|
|
)} ${this.getOrganizerStart().format("D")}, ${this.getOrganizerStart().format("YYYY")}`,
|
|
|
|
});
|
|
|
|
|
|
|
|
return `
|
|
|
|
<!doctype html>
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
|
|
|
${emailHead(headerContent)}
|
|
|
|
<body style="word-spacing:normal;background-color:#F5F5F5;">
|
|
|
|
<div style="background-color:#F5F5F5;">
|
|
|
|
${emailSchedulingBodyHeader("calendarCircle")}
|
2021-12-01 10:32:08 +00:00
|
|
|
${emailScheduledBodyHeaderContent(
|
2022-01-27 20:32:53 +00:00
|
|
|
this.calEvent.organizer.language.translate("event_still_awaiting_approval"),
|
|
|
|
this.calEvent.organizer.language.translate("someone_requested_an_event")
|
2021-12-01 10:32:08 +00:00
|
|
|
)}
|
|
|
|
${emailSchedulingBodyDivider()}
|
2021-11-26 11:03:43 +00:00
|
|
|
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#FFFFFF" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
|
|
|
|
<div style="background:#FFFFFF;background-color:#FFFFFF;margin:0px auto;max-width:600px;">
|
|
|
|
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#FFFFFF;background-color:#FFFFFF;width:100%;">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td style="border-left:1px solid #E1E1E1;border-right:1px solid #E1E1E1;direction:ltr;font-size:0px;padding:0px;text-align:center;">
|
|
|
|
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]-->
|
|
|
|
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
|
|
<div style="font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:500;line-height:1;text-align:left;color:#3E3E3E;">
|
|
|
|
${this.getWhat()}
|
|
|
|
${this.getWhen()}
|
|
|
|
${this.getWho()}
|
|
|
|
${this.getLocation()}
|
|
|
|
${this.getAdditionalNotes()}
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<!--[if mso | IE]></td></tr></table><![endif]-->
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2021-12-01 10:32:08 +00:00
|
|
|
${emailSchedulingBodyDivider()}
|
2021-11-26 11:03:43 +00:00
|
|
|
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#FFFFFF" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
|
|
|
|
<div style="background:#FFFFFF;background-color:#FFFFFF;margin:0px auto;max-width:600px;">
|
|
|
|
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#FFFFFF;background-color:#FFFFFF;width:100%;">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td style="border-bottom:1px solid #E1E1E1;border-left:1px solid #E1E1E1;border-right:1px solid #E1E1E1;direction:ltr;font-size:0px;padding:0px;text-align:center;">
|
|
|
|
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]-->
|
|
|
|
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td align="center" vertical-align="middle" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;">
|
|
|
|
<tr>
|
|
|
|
<td align="center" bgcolor="#292929" role="presentation" style="border:none;border-radius:3px;cursor:auto;mso-padding-alt:10px 25px;background:#292929;" valign="middle">
|
|
|
|
<p style="display:inline-block;background:#292929;color:#ffffff;font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:500;line-height:120%;margin:0;text-decoration:none;text-transform:none;padding:10px 25px;mso-padding-alt:0px;border-radius:3px;">
|
|
|
|
${this.getManageLink()}
|
|
|
|
</p>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
|
|
|
<div style="font-family:Roboto, Helvetica, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"></div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<!--[if mso | IE]></td></tr></table><![endif]-->
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2021-12-01 10:32:08 +00:00
|
|
|
${emailBodyLogo()}
|
2021-11-26 11:03:43 +00:00
|
|
|
<!--[if mso | IE]></td></tr></table><![endif]-->
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getManageLink(): string {
|
2022-01-27 20:32:53 +00:00
|
|
|
const manageText = this.calEvent.organizer.language.translate("confirm_or_reject_request");
|
2022-03-26 00:39:38 +00:00
|
|
|
const manageLink = process.env.NEXT_PUBLIC_WEBAPP_URL + "/bookings/upcoming";
|
2021-12-01 10:32:08 +00:00
|
|
|
return `<a style="color: #FFFFFF; text-decoration: none;" href="${manageLink}" target="_blank">${manageText} <img src="${linkIcon()}" width="12px"></img></a>`;
|
2021-11-26 11:03:43 +00:00
|
|
|
}
|
|
|
|
}
|