feat: email workflow templates translation (#20674)
* Add translations in respective files * implement multilingual support for email templates * fix: indentation in common.js & typos in common.js and update.handler.ts
This commit is contained in:
1 parent
417acdaacb
commit
381c462660
52 files changed
+630
-76
No files matched your search
@@ -245,10 +245,10 @@ export async function handler(req: NextRequest) {
|
||||
const brandingDisabled = reminder.booking.eventType?.team
|
||||
? !!reminder.booking.eventType?.team?.hideBranding
|
||||
: !!reminder.booking.user?.hideBranding;
|
||||
|
||||
emailContent = emailReminderTemplate({
|
||||
isEditingMode: false,
|
||||
locale: reminder.booking.user?.locale || "en",
|
||||
t: await getTranslation(reminder.booking.user?.locale ?? "en", "common"),
|
||||
action: reminder.workflowStep.action,
|
||||
timeFormat: getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat),
|
||||
startTime: reminder.booking.startTime.toISOString() || "",
|
||||
@@ -276,6 +276,7 @@ export async function handler(req: NextRequest) {
|
||||
isEditingMode: true,
|
||||
locale: reminder.booking.user?.locale || "en",
|
||||
action: reminder.workflowStep.action || WorkflowActions.EMAIL_ADDRESS,
|
||||
t: await getTranslation(reminder.booking.user?.locale ?? "en", "common"),
|
||||
timeFormat: getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat),
|
||||
startTime: reminder.booking.startTime.toISOString() || "",
|
||||
endTime: reminder.booking.endTime.toISOString() || "",
|
||||
@@ -383,6 +384,7 @@ export async function handler(req: NextRequest) {
|
||||
emailContent = emailReminderTemplate({
|
||||
isEditingMode: false,
|
||||
locale: reminder.booking.user?.locale || "en",
|
||||
t: await getTranslation(reminder.booking.user?.locale ?? "en", "common"),
|
||||
action: WorkflowActions.EMAIL_ATTENDEE,
|
||||
timeFormat: getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat),
|
||||
startTime: reminder.booking.startTime.toISOString() || "",
|
||||
|
||||
@@ -133,6 +133,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
const template = getTemplateBodyForAction({
|
||||
action,
|
||||
locale: i18n.language,
|
||||
t,
|
||||
template: step.template ?? WorkflowTemplates.REMINDER,
|
||||
timeFormat,
|
||||
});
|
||||
@@ -143,6 +144,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
const subjectTemplate = emailReminderTemplate({
|
||||
isEditingMode: true,
|
||||
locale: i18n.language,
|
||||
t,
|
||||
action: form.getValues(`steps.${step.stepNumber - 1}.action`),
|
||||
timeFormat,
|
||||
}).emailSubject;
|
||||
@@ -443,6 +445,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: val.value,
|
||||
locale: i18n.language,
|
||||
t,
|
||||
template: WorkflowTemplates.REMINDER,
|
||||
timeFormat,
|
||||
});
|
||||
@@ -762,6 +765,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
const template = getTemplateBodyForAction({
|
||||
action,
|
||||
locale: i18n.language,
|
||||
t,
|
||||
template: val.value ?? WorkflowTemplates.REMINDER,
|
||||
timeFormat,
|
||||
});
|
||||
@@ -775,6 +779,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
emailReminderTemplate({
|
||||
isEditingMode: true,
|
||||
locale: i18n.language,
|
||||
t,
|
||||
action,
|
||||
timeFormat,
|
||||
}).emailSubject
|
||||
@@ -786,6 +791,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
||||
isEditingMode: true,
|
||||
locale: i18n.language,
|
||||
action,
|
||||
t,
|
||||
timeFormat,
|
||||
}).emailSubject
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { WorkflowTriggerEvents } from "@prisma/client";
|
||||
import type { TFunction } from "i18next";
|
||||
|
||||
import type { TimeFormat } from "@calcom/lib/timeFormat";
|
||||
import { WorkflowActions, WorkflowTemplates } from "@calcom/prisma/enums";
|
||||
@@ -113,11 +114,13 @@ export function getWhatsappTemplateForAction(
|
||||
export function getTemplateBodyForAction({
|
||||
action,
|
||||
locale,
|
||||
t,
|
||||
template,
|
||||
timeFormat,
|
||||
}: {
|
||||
action: WorkflowActions;
|
||||
locale: string;
|
||||
t: TFunction;
|
||||
template: WorkflowTemplates;
|
||||
timeFormat: TimeFormat;
|
||||
}): string | null {
|
||||
@@ -132,5 +135,5 @@ export function getTemplateBodyForAction({
|
||||
|
||||
// If not a whatsapp action then it's an email action
|
||||
const templateFunction = getEmailTemplateFunction(template);
|
||||
return templateFunction({ isEditingMode: true, locale, action, timeFormat }).emailBody;
|
||||
return templateFunction({ isEditingMode: true, locale, t, action, timeFormat }).emailBody;
|
||||
}
|
||||
@@ -177,6 +177,7 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) =>
|
||||
emailContent = emailReminderTemplate({
|
||||
isEditingMode: false,
|
||||
locale: evt.organizer.language.locale,
|
||||
t: await getTranslation(evt.organizer.language.locale || "en", "common"),
|
||||
action,
|
||||
timeFormat: evt.organizer.timeFormat,
|
||||
startTime,
|
||||
@@ -193,6 +194,7 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) =>
|
||||
isEditingMode: true,
|
||||
locale: evt.organizer.language.locale,
|
||||
action,
|
||||
t: await getTranslation(evt.organizer.language.locale || "en", "common"),
|
||||
timeFormat: evt.organizer.timeFormat,
|
||||
startTime,
|
||||
endTime,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { TFunction } from "i18next";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { TimeFormat } from "@calcom/lib/timeFormat";
|
||||
@@ -7,6 +9,7 @@ const emailRatingTemplate = ({
|
||||
isEditingMode,
|
||||
locale,
|
||||
action,
|
||||
t,
|
||||
timeFormat,
|
||||
startTime,
|
||||
endTime,
|
||||
@@ -21,6 +24,7 @@ const emailRatingTemplate = ({
|
||||
isEditingMode: boolean;
|
||||
locale: string;
|
||||
action: WorkflowActions;
|
||||
t: TFunction;
|
||||
timeFormat?: TimeFormat;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
@@ -52,26 +56,30 @@ const emailRatingTemplate = ({
|
||||
endTime = dayjs(endTime).tz(timeZone).locale(locale).format(currentTimeFormat);
|
||||
}
|
||||
|
||||
const emailSubject = `How was your recent experience? ${eventName}`;
|
||||
const emailSubject = `${t("experience_review_prompt")} ${eventName}`;
|
||||
|
||||
const introHtml = `<p>Hi${
|
||||
name ? ` ${name}` : ""
|
||||
},<br><br>We're always looking to improve our customer's experience. How satisfied were you with your recent meeting?<br></p>`;
|
||||
const introHtml = `<p>${t("hi")}${name ? ` ${name}` : ""},<br><br>${t(
|
||||
"improve_customer_experience_message"
|
||||
)} ${t("meeting_satisfaction_question")}<br></p>`;
|
||||
|
||||
const ratingHtml = `<h6><a href="${ratingUrl}=1">😠 </a> <a href="${ratingUrl}=2">🙁 </a> <a href="${ratingUrl}=3">😐 </a> <a href="${ratingUrl}=4">😄 </a> <a href="${ratingUrl}=5">😍</a></h6>`;
|
||||
|
||||
const noShowHtml = `${organizer} didn't join the meeting?<a href="${noShowUrl}"> Reschedule here</a><br><br>`;
|
||||
const noShowHtml = `${organizer} ${t("meeting_not_joined_question")}<a href="${noShowUrl}"> ${t(
|
||||
"reschedule_cta_short"
|
||||
)}</a><br><br>`;
|
||||
|
||||
const eventHtml = `<strong>Event: </strong>${eventName}<br><br>`;
|
||||
const eventHtml = `<strong>${t("event_upper_case")}: </strong>${eventName}<br><br>`;
|
||||
|
||||
const dateTimeHtml = `<strong>Date & Time: </strong>${eventDate} - ${endTime} (${timeZone})<br><br>`;
|
||||
const dateTimeHtml = `<strong>${t(
|
||||
"date_and_time"
|
||||
)}: </strong>${eventDate} - ${endTime} (${timeZone})<br><br>`;
|
||||
|
||||
const attendeeHtml = `<strong>Attendees: </strong>You & ${organizer}<br><br>`;
|
||||
const attendeeHtml = `<strong>${t("attendees")}: </strong>${t("you_and_conjunction")} ${organizer}<br><br>`;
|
||||
|
||||
const branding =
|
||||
!isBrandingDisabled && !isEditingMode ? `<div>_<br><br>Scheduling by ${APP_NAME}</div>` : "";
|
||||
!isBrandingDisabled && !isEditingMode ? `<div>_<br><br>${t("scheduling_by")} ${APP_NAME}</div>` : "";
|
||||
|
||||
const endingHtml = `This survey was triggered by a Workflow in Cal.${branding}`;
|
||||
const endingHtml = `${t("email_survey_triggered_by_workflow")}${branding}`;
|
||||
|
||||
const emailBody = `<body>${introHtml}${ratingHtml}<p>${noShowHtml}${eventHtml}${dateTimeHtml}${attendeeHtml}${endingHtml}</p></body>`;
|
||||
|
||||
@@ -81,4 +89,4 @@ const emailRatingTemplate = ({
|
||||
export default emailRatingTemplate;
|
||||
|
||||
export const plainTextTemplate =
|
||||
"Hi {ORGANIZER},We're always looking to improve our customer's experience. How satisfied were you with your recent meeting?😠 🙁 😐 😄 😍{ORGANIZER} didn't join the meeting? Reschedule hereEvent: {EVENT_NAME}Date & Time: {EVENT_DATE_ddd, MMM D, YYYY h:mma} - {EVENT_END_TIME} ({TIMEZONE})Attendees: You & {ORGANIZER}This survey was triggered by a Workflow in Cal.";
|
||||
"Hi {ORGANIZER},We're always looking to improve our customer's experience. How satisfied were you with your recent meeting?😠 🙁 😐 😄 😍{ORGANIZER} didn't join the meeting? Reschedule here.Event: {EVENT_NAME}Date & Time: {EVENT_DATE_ddd, MMM D, YYYY h:mma} - {EVENT_END_TIME} ({TIMEZONE})Attendees: You & {ORGANIZER}This survey was triggered by a Workflow in Cal.";
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { TFunction } from "i18next";
|
||||
|
||||
import { guessEventLocationType } from "@calcom/app-store/locations";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
@@ -7,6 +9,7 @@ import { WorkflowActions } from "@calcom/prisma/enums";
|
||||
const emailReminderTemplate = ({
|
||||
isEditingMode,
|
||||
locale,
|
||||
t,
|
||||
action,
|
||||
timeFormat,
|
||||
startTime,
|
||||
@@ -21,6 +24,7 @@ const emailReminderTemplate = ({
|
||||
}: {
|
||||
isEditingMode: boolean;
|
||||
locale: string;
|
||||
t: TFunction;
|
||||
action?: WorkflowActions;
|
||||
timeFormat?: TimeFormat;
|
||||
startTime?: string;
|
||||
@@ -53,23 +57,32 @@ const emailReminderTemplate = ({
|
||||
endTime = dayjs(endTime).tz(timeZone).locale(locale).format(currentTimeFormat);
|
||||
}
|
||||
|
||||
const emailSubject = `Reminder: ${eventName} - ${eventDate}`;
|
||||
const emailSubject = `${t("reminder")}: ${eventName} - ${eventDate}`;
|
||||
|
||||
const introHtml = `<body>Hi${
|
||||
name ? ` ${name}` : ""
|
||||
},<br><br>This is a reminder about your upcoming event.<br><br>`;
|
||||
const introHtml = `<body>${t("hi")}${name ? ` ${name}` : ""},<br><br>${t?.(
|
||||
"email_reminder_upcoming_event_notice"
|
||||
)}<br><br>`;
|
||||
|
||||
const eventHtml = `<div><strong class="editor-text-bold">Event: </strong></div>${eventName}<br><br>`;
|
||||
const eventHtml = `<div><strong class="editor-text-bold">${t(
|
||||
"event_upper_case"
|
||||
)}: </strong></div>${eventName}<br><br>`;
|
||||
|
||||
const dateTimeHtml = `<div><strong class="editor-text-bold">Date & Time: </strong></div>${eventDate} - ${endTime} (${timeZone})<br><br>`;
|
||||
const dateTimeHtml = `<div><strong class="editor-text-bold">${t(
|
||||
"date_and_time"
|
||||
)}: </strong></div>${eventDate} - ${endTime} (${timeZone})<br><br>`;
|
||||
|
||||
const attendeeHtml = `<div><strong class="editor-text-bold">Attendees: </strong></div>You & ${otherPerson}<br><br>`;
|
||||
const attendeeHtml = `<div><strong class="editor-text-bold">${t("attendees")}: </strong></div>${t(
|
||||
"you_and_conjunction"
|
||||
)} ${otherPerson}<br><br>`;
|
||||
|
||||
const locationHtml = `<div><strong class="editor-text-bold">Location: </strong></div>${locationString}<br><br>`;
|
||||
const locationHtml = `<div><strong class="editor-text-bold">${t(
|
||||
"location"
|
||||
)}: </strong></div>${locationString}<br><br>`;
|
||||
|
||||
const branding = !isBrandingDisabled && !isEditingMode ? `<br><br>_<br><br>Scheduling by ${APP_NAME}` : "";
|
||||
const branding =
|
||||
!isBrandingDisabled && !isEditingMode ? `<br><br>_<br><br>${t("scheduling_by")} ${APP_NAME}` : "";
|
||||
|
||||
const endingHtml = `This reminder was triggered by a Workflow in Cal.${branding}</body>`;
|
||||
const endingHtml = `${t("email_reminder_triggered_by_workflow")}${branding}</body>`;
|
||||
|
||||
const emailBody = introHtml + eventHtml + dateTimeHtml + attendeeHtml + locationHtml + endingHtml;
|
||||
|
||||
@@ -78,5 +91,4 @@ const emailReminderTemplate = ({
|
||||
|
||||
export default emailReminderTemplate;
|
||||
|
||||
export const plainTextTemplate =
|
||||
"Hi {ORGANIZER},This is a reminder about your upcoming event.Event: {EVENT_NAME}Date & Time: {EVENT_DATE_ddd, MMM D, YYYY h:mma} - {EVENT_END_TIME} ({TIMEZONE})Attendees: You & {ATTENDEE}Location: {LOCATION} {MEETING_URL}This reminder was triggered by a Workflow in Cal.";
|
||||
export const plainTextTemplate = `Hi {ORGANIZER},This is a reminder about your upcoming event.Event: {EVENT_NAME}Date & Time: {EVENT_DATE_ddd, MMM D, YYYY h:mma} - {EVENT_END_TIME} ({TIMEZONE})Attendees: You & {ATTENDEE}Location: {LOCATION} {MEETING_URL}This reminder was triggered by a Workflow in Cal.`;
|
||||
@@ -1,12 +1,28 @@
|
||||
import { createInstance } from "i18next";
|
||||
import { expect, test, describe } from "vitest";
|
||||
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { TimeFormat } from "@calcom/lib/timeFormat";
|
||||
import { WorkflowActions, WorkflowTemplates } from "@calcom/prisma/enums";
|
||||
import en from "@calcom/web/public/static/locales/en/common.json";
|
||||
|
||||
import { getTemplateBodyForAction } from "../actionHelperFunctions";
|
||||
import compareReminderBodyToTemplate from "../compareReminderBodyToTemplate";
|
||||
import plainTextReminderTemplates from "../reminders/templates/plainTextTemplates";
|
||||
|
||||
const translation = async () => {
|
||||
const _i18n = createInstance();
|
||||
await _i18n.init({
|
||||
lng: "en",
|
||||
resources: {
|
||||
en: {
|
||||
translation: en,
|
||||
},
|
||||
},
|
||||
});
|
||||
return _i18n.getFixedT("en");
|
||||
};
|
||||
|
||||
describe("compareReminderBodyToTemplate", () => {
|
||||
test("should return true if reminderBody and template are the same", () => {
|
||||
const reminderBody = "<p>Test</p>";
|
||||
@@ -21,12 +37,13 @@ describe("compareReminderBodyToTemplate", () => {
|
||||
});
|
||||
|
||||
describe("email templates", () => {
|
||||
test("reminder", () => {
|
||||
test("reminder", async () => {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: WorkflowActions.EMAIL_HOST,
|
||||
template: WorkflowTemplates.REMINDER,
|
||||
timeFormat: TimeFormat.TWELVE_HOUR,
|
||||
locale: "en",
|
||||
t: await translation(),
|
||||
});
|
||||
|
||||
if (!template) throw new Error("template not found");
|
||||
@@ -35,12 +52,13 @@ describe("compareReminderBodyToTemplate", () => {
|
||||
expect(compareReminderBodyToTemplate({ reminderBody, template })).toBe(true);
|
||||
});
|
||||
|
||||
test("rating", () => {
|
||||
test("rating", async () => {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: WorkflowActions.EMAIL_HOST,
|
||||
template: WorkflowTemplates.RATING,
|
||||
timeFormat: TimeFormat.TWELVE_HOUR,
|
||||
locale: "en",
|
||||
t: await translation(),
|
||||
});
|
||||
|
||||
if (!template) throw new Error("template not found");
|
||||
@@ -51,12 +69,13 @@ describe("compareReminderBodyToTemplate", () => {
|
||||
});
|
||||
|
||||
describe("sms templates", () => {
|
||||
test("reminder", () => {
|
||||
test("reminder", async () => {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: WorkflowActions.SMS_ATTENDEE,
|
||||
template: WorkflowTemplates.REMINDER,
|
||||
timeFormat: TimeFormat.TWELVE_HOUR,
|
||||
locale: "en",
|
||||
t: await getTranslation("en", "common"),
|
||||
});
|
||||
|
||||
if (!template) throw new Error("template not found");
|
||||
@@ -67,12 +86,13 @@ describe("compareReminderBodyToTemplate", () => {
|
||||
});
|
||||
|
||||
describe("whatsapp templates", () => {
|
||||
test("reminder", () => {
|
||||
test("reminder", async () => {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: WorkflowActions.WHATSAPP_ATTENDEE,
|
||||
template: WorkflowTemplates.REMINDER,
|
||||
timeFormat: TimeFormat.TWELVE_HOUR,
|
||||
locale: "en",
|
||||
t: await getTranslation("en", "common"),
|
||||
});
|
||||
|
||||
if (!template) throw new Error("template not found");
|
||||
@@ -81,12 +101,13 @@ describe("compareReminderBodyToTemplate", () => {
|
||||
expect(compareReminderBodyToTemplate({ reminderBody, template })).toBe(true);
|
||||
});
|
||||
|
||||
test("rescheduled", () => {
|
||||
test("rescheduled", async () => {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: WorkflowActions.WHATSAPP_ATTENDEE,
|
||||
template: WorkflowTemplates.RESCHEDULED,
|
||||
timeFormat: TimeFormat.TWELVE_HOUR,
|
||||
locale: "en",
|
||||
t: await getTranslation("en", "common"),
|
||||
});
|
||||
|
||||
if (!template) throw new Error("template not found");
|
||||
@@ -95,12 +116,13 @@ describe("compareReminderBodyToTemplate", () => {
|
||||
expect(compareReminderBodyToTemplate({ reminderBody, template })).toBe(true);
|
||||
});
|
||||
|
||||
test("completed", () => {
|
||||
test("completed", async () => {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: WorkflowActions.WHATSAPP_ATTENDEE,
|
||||
template: WorkflowTemplates.COMPLETED,
|
||||
timeFormat: TimeFormat.TWELVE_HOUR,
|
||||
locale: "en",
|
||||
t: await getTranslation("en", "common"),
|
||||
});
|
||||
|
||||
if (!template) throw new Error("template not found");
|
||||
@@ -109,12 +131,13 @@ describe("compareReminderBodyToTemplate", () => {
|
||||
expect(compareReminderBodyToTemplate({ reminderBody, template })).toBe(true);
|
||||
});
|
||||
|
||||
test("canceled", () => {
|
||||
test("canceled", async () => {
|
||||
const template = getTemplateBodyForAction({
|
||||
action: WorkflowActions.WHATSAPP_ATTENDEE,
|
||||
template: WorkflowTemplates.CANCELLED,
|
||||
timeFormat: TimeFormat.TWELVE_HOUR,
|
||||
locale: "en",
|
||||
t: await getTranslation("en", "common"),
|
||||
});
|
||||
|
||||
if (!template) throw new Error("template not found");
|
||||
|
||||
@@ -7,6 +7,7 @@ import compareReminderBodyToTemplate from "@calcom/features/ee/workflows/lib/com
|
||||
import { lockUser, LockReason } from "@calcom/lib/autoLock";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { scheduleWorkflowNotifications } from "@calcom/trpc/server/routers/viewer/workflows/util";
|
||||
@@ -67,6 +68,7 @@ export async function scanWorkflowBody(payload: string) {
|
||||
const defaultTemplate = getTemplateBodyForAction({
|
||||
action: workflowStep.action,
|
||||
locale: workflowStep.workflow.user?.locale ?? "en",
|
||||
t: await getTranslation(workflowStep.workflow.user?.locale ?? "en", "common"),
|
||||
template: workflowStep.template,
|
||||
timeFormat,
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Workflow } from "@prisma/client";
|
||||
|
||||
import emailReminderTemplate from "@calcom/ee/workflows/lib/reminders/templates/emailReminderTemplate";
|
||||
import { SENDER_NAME } from "@calcom/lib/constants";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
@@ -69,6 +70,7 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
|
||||
const renderedEmailTemplate = emailReminderTemplate({
|
||||
isEditingMode: true,
|
||||
locale: ctx.user.locale,
|
||||
t: await getTranslation(ctx.user.locale, "common"),
|
||||
action: WorkflowActions.EMAIL_ATTENDEE,
|
||||
timeFormat: getTimeFormatStringFromUserTimeFormat(ctx.user.timeFormat),
|
||||
});
|
||||
|
||||
@@ -355,7 +355,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
|
||||
if (isEmailAction(newStep.action)) {
|
||||
// on free plans always use predefined templates
|
||||
const { emailBody, emailSubject } = getEmailTemplateText(newStep.template, {
|
||||
const { emailBody, emailSubject } = await getEmailTemplateText(newStep.template, {
|
||||
locale: ctx.user.locale,
|
||||
action: newStep.action,
|
||||
timeFormat: ctx.user.timeFormat,
|
||||
@@ -430,7 +430,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
}
|
||||
|
||||
// on free plans always use predefined templates
|
||||
const { emailBody, emailSubject } = getEmailTemplateText(newStep.template, {
|
||||
const { emailBody, emailSubject } = await getEmailTemplateText(newStep.template, {
|
||||
locale: ctx.user.locale,
|
||||
action: newStep.action,
|
||||
timeFormat: ctx.user.timeFormat,
|
||||
|
||||
@@ -20,6 +20,7 @@ import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
|
||||
import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";
|
||||
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
|
||||
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
|
||||
import prisma from "@calcom/prisma";
|
||||
@@ -865,7 +866,7 @@ export const getEventTypeWorkflows = async (
|
||||
return workflows.map((workflow) => ({ workflow }));
|
||||
};
|
||||
|
||||
export function getEmailTemplateText(
|
||||
export async function getEmailTemplateText(
|
||||
template: WorkflowTemplates,
|
||||
params: { locale: string; action: WorkflowActions; timeFormat: number | null }
|
||||
) {
|
||||
@@ -876,6 +877,7 @@ export function getEmailTemplateText(
|
||||
let { emailBody, emailSubject } = emailReminderTemplate({
|
||||
isEditingMode: true,
|
||||
locale,
|
||||
t: await getTranslation(locale ?? "en", "common"),
|
||||
action,
|
||||
timeFormat,
|
||||
});
|
||||
@@ -885,6 +887,7 @@ export function getEmailTemplateText(
|
||||
isEditingMode: true,
|
||||
locale,
|
||||
action,
|
||||
t: await getTranslation(locale ?? "en", "common"),
|
||||
timeFormat,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user