Found via `codespell -q 3 -S "*.svg,./apps/web/public/static/locales,./packages/app-store/stripepayment/lib/currencyOptions.ts,./packages/lib/freeEmailDomainCheck/freeEmailDomains.ts" -L afterall,atleast,datea,fo,incase,ist,nam,notin,optionel,perview,reccuring` Closes #19219
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import dayjs from "@calcom/dayjs";
|
|
import { TimeFormat } from "@calcom/lib/timeFormat";
|
|
import { WorkflowActions } from "@calcom/prisma/enums";
|
|
|
|
const smsReminderTemplate = (
|
|
isEditingMode: boolean,
|
|
locale: string,
|
|
action?: WorkflowActions,
|
|
timeFormat?: TimeFormat,
|
|
startTime?: string,
|
|
eventName?: string,
|
|
timeZone?: string,
|
|
attendee?: string,
|
|
name?: string
|
|
) => {
|
|
const currentTimeFormat = timeFormat || TimeFormat.TWELVE_HOUR;
|
|
|
|
let eventDate;
|
|
if (isEditingMode) {
|
|
eventName = "{EVENT_NAME}";
|
|
timeZone = "{TIMEZONE}";
|
|
startTime = `{EVENT_TIME_${currentTimeFormat}}`;
|
|
|
|
eventDate = "{EVENT_DATE_YYYY MMM D}";
|
|
attendee = action === WorkflowActions.SMS_ATTENDEE ? "{ORGANIZER}" : "{ATTENDEE}";
|
|
name = action === WorkflowActions.SMS_ATTENDEE ? "{ATTENDEE}" : "{ORGANIZER}";
|
|
} else {
|
|
eventDate = dayjs(startTime).tz(timeZone).locale(locale).format("YYYY MMM D");
|
|
startTime = dayjs(startTime).tz(timeZone).locale(locale).format(currentTimeFormat);
|
|
}
|
|
|
|
const templateOne = `Hi${
|
|
name ? ` ${name}` : ``
|
|
}, this is a reminder that your meeting (${eventName}) with ${attendee} is on ${eventDate} at ${startTime} ${timeZone}.`;
|
|
|
|
//Twilio recommends message to be no longer than 320 characters
|
|
if (templateOne.length <= 320) return templateOne;
|
|
|
|
const templateTwo = `Hi, this is a reminder that your meeting with ${attendee} is on ${eventDate} at ${startTime} ${timeZone}`;
|
|
|
|
//Twilio supports up to 1600 characters
|
|
if (templateTwo.length <= 1600) return templateTwo;
|
|
|
|
return null;
|
|
};
|
|
|
|
export default smsReminderTemplate;
|