Improve design of workflow reminder email (#3685)
parent
fc4b88e222
commit
ca7a78dcda
|
@ -98,6 +98,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||
case WorkflowTemplates.REMINDER:
|
||||
emailContent = emailReminderTemplate(
|
||||
reminder.booking?.startTime.toISOString() || "",
|
||||
reminder.booking?.endTime.toISOString() || "",
|
||||
reminder.booking?.eventType?.title || "",
|
||||
timeZone || "",
|
||||
attendeeName || "",
|
||||
|
|
|
@ -39,7 +39,7 @@ export const scheduleEmailReminder = async (
|
|||
workflowStepId: number,
|
||||
template: WorkflowTemplates
|
||||
) => {
|
||||
const { startTime } = evt;
|
||||
const { startTime, endTime } = evt;
|
||||
const uid = evt.uid as string;
|
||||
const currentDate = dayjs();
|
||||
const timeUnit: timeUnitLowerCase | undefined =
|
||||
|
@ -71,7 +71,7 @@ export const scheduleEmailReminder = async (
|
|||
|
||||
switch (template) {
|
||||
case WorkflowTemplates.REMINDER:
|
||||
emailContent = emailReminderTemplate(startTime, evt.title, timeZone, attendeeName, name);
|
||||
emailContent = emailReminderTemplate(startTime, endTime, evt.title, timeZone, attendeeName, name);
|
||||
break;
|
||||
case WorkflowTemplates.CUSTOM:
|
||||
const variables: VariablesType = {
|
||||
|
|
|
@ -30,6 +30,7 @@ export type BookingInfo = {
|
|||
timeZone: string;
|
||||
};
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
title: string;
|
||||
location?: string | null;
|
||||
additionalNotes?: string | null;
|
||||
|
|
|
@ -1,27 +1,39 @@
|
|||
import { WorkflowActions } from ".prisma/client";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
|
||||
const emailReminderTemplate = (
|
||||
startTime: string,
|
||||
endTime: string,
|
||||
eventName: string,
|
||||
timeZone: string,
|
||||
attendee: string,
|
||||
name: string
|
||||
) => {
|
||||
const emailSubject = `Reminder: ${eventName} on ${dayjs(startTime)
|
||||
const emailSubject = `Reminder: ${eventName} - ${dayjs(startTime)
|
||||
.tz(timeZone)
|
||||
.format("YYYY MMM D")} at ${dayjs(startTime).tz(timeZone).format("h:mmA")} ${timeZone}.`;
|
||||
.format("ddd, MMM D, YYYY")} ${dayjs(startTime).tz(timeZone).format("H:mmA")}`;
|
||||
|
||||
const templateBodyText = `Hi ${name}, this is a reminder that your meeting (${eventName}) with ${attendee} is on ${dayjs(
|
||||
const templateBodyText = `Hi ${name},this is a reminder that your meeting (${eventName}) with ${attendee} is on ${dayjs(
|
||||
startTime
|
||||
)
|
||||
.tz(timeZone)
|
||||
.format("YYYY MMM D")} at ${dayjs(startTime).tz(timeZone).format("h:mmA")} ${timeZone}.`;
|
||||
|
||||
const templateBodyHtml = `<body>Hi ${name},<br><br>This is a reminder that your meeting (${eventName}) with ${attendee} is on ${dayjs(
|
||||
startTime
|
||||
)
|
||||
const introHtml = `<body>Hi ${name},<br><br>This is a reminder about your upcoming event.<br><br>`;
|
||||
|
||||
const eventHtml = `<div style="font-weight: bold;">Event:</div>${eventName}<br><br>`;
|
||||
|
||||
const dateTimeHtml = `<div style="font-weight: bold;">Date & Time:</div>${dayjs(startTime)
|
||||
.tz(timeZone)
|
||||
.format("YYYY MMM D")} at ${dayjs(startTime).tz(timeZone).format("h:mmA")} ${timeZone}.<body>`;
|
||||
.format("ddd, MMM D, YYYY H:mmA")} - ${dayjs(endTime)
|
||||
.tz(timeZone)
|
||||
.format("H:mmA")} (${timeZone})<br><br>`;
|
||||
|
||||
const attendeeHtml = `<div style="font-weight: bold;">Attendees:</div>You & ${attendee}<br><br>`;
|
||||
|
||||
const endingHtml = `This reminder was triggered by a Workflow in Cal.<br><br>_<br><br>Scheduling by Cal.com</body>`;
|
||||
|
||||
const templateBodyHtml = introHtml + eventHtml + dateTimeHtml + attendeeHtml + endingHtml;
|
||||
|
||||
const emailBody = { text: templateBodyText, html: templateBodyHtml };
|
||||
|
||||
|
|
|
@ -348,6 +348,7 @@ export const workflowsRouter = createProtectedRouter()
|
|||
}
|
||||
: { name: "", email: "", timeZone: "", language: { locale: "" } },
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
title: booking.title,
|
||||
language: { locale: booking?.user?.locale || "" },
|
||||
};
|
||||
|
@ -505,6 +506,7 @@ export const workflowsRouter = createProtectedRouter()
|
|||
}
|
||||
: { name: "", email: "", timeZone: "", language: { locale: "" } },
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
title: booking.title,
|
||||
language: { locale: booking?.user?.locale || "" },
|
||||
};
|
||||
|
@ -604,6 +606,7 @@ export const workflowsRouter = createProtectedRouter()
|
|||
}
|
||||
: { name: "", email: "", timeZone: "", language: { locale: "" } },
|
||||
startTime: booking.startTime.toISOString(),
|
||||
endTime: booking.endTime.toISOString(),
|
||||
title: booking.title,
|
||||
language: { locale: booking?.user?.locale || "" },
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue