import { guessEventLocationType } from "@calcom/app-store/locations"; import dayjs from "@calcom/dayjs"; import { APP_NAME } from "@calcom/lib/constants"; import { TimeFormat } from "@calcom/lib/timeFormat"; import { WorkflowActions } from "@calcom/prisma/enums"; const emailReminderTemplate = ( isEditingMode: boolean, locale: string, action?: WorkflowActions, timeFormat?: TimeFormat, startTime?: string, endTime?: string, eventName?: string, timeZone?: string, location?: string, meetingUrl?: string, otherPerson?: string, name?: string, isBrandingDisabled?: boolean ) => { const currentTimeFormat = timeFormat || TimeFormat.TWELVE_HOUR; const dateTimeFormat = `ddd, MMM D, YYYY ${currentTimeFormat}`; let eventDate = ""; let locationString = `${guessEventLocationType(location)?.label || location} ${meetingUrl}`; if (isEditingMode) { endTime = "{EVENT_END_TIME}"; eventName = "{EVENT_NAME}"; timeZone = "{TIMEZONE}"; locationString = "{LOCATION} {MEETING_URL}"; otherPerson = action === WorkflowActions.EMAIL_ATTENDEE ? "{ORGANIZER}" : "{ATTENDEE}"; name = action === WorkflowActions.EMAIL_ATTENDEE ? "{ATTENDEE}" : "{ORGANIZER}"; eventDate = `{EVENT_DATE_${dateTimeFormat}}`; } else { eventDate = dayjs(startTime).tz(timeZone).locale(locale).format(dateTimeFormat); endTime = dayjs(endTime).tz(timeZone).locale(locale).format(currentTimeFormat); } const emailSubject = `Reminder: ${eventName} - ${eventDate}`; const introHtml = `Hi${ name ? ` ${name}` : "" },

This is a reminder about your upcoming event.

`; const eventHtml = `
Event:
${eventName}

`; const dateTimeHtml = `
Date & Time:
${eventDate} - ${endTime} (${timeZone})

`; const attendeeHtml = `
Attendees:
You & ${otherPerson}

`; const locationHtml = `
Location:
${locationString}

`; const branding = !isBrandingDisabled && !isEditingMode ? `

_

Scheduling by ${APP_NAME}` : ""; const endingHtml = `This reminder was triggered by a Workflow in Cal.${branding}`; const emailBody = introHtml + eventHtml + dateTimeHtml + attendeeHtml + locationHtml + endingHtml; return { emailSubject, emailBody }; }; export default emailReminderTemplate;