Skip to content

Commit 82a500a

Browse files
authoredDec 5, 2024
fix: days of the week in different language in the workflow (#17850)
* fix: days of the week in different language in the workflow * Update
1 parent 2408337 commit 82a500a

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed
 

‎packages/features/ee/workflows/api/scheduleEmailReminders.ts

+2
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
240240
} else if (reminder.workflowStep.template === WorkflowTemplates.REMINDER) {
241241
emailContent = emailReminderTemplate(
242242
false,
243+
reminder.booking.user?.locale || "en",
243244
reminder.workflowStep.action,
244245
getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat),
245246
reminder.booking.startTime.toISOString() || "",
@@ -366,6 +367,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
366367

367368
emailContent = emailReminderTemplate(
368369
false,
370+
reminder.booking.user?.locale || "en",
369371
WorkflowActions.EMAIL_ATTENDEE,
370372
getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat),
371373
reminder.booking.startTime.toISOString() || "",

‎packages/features/ee/workflows/components/WorkflowStepContainer.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const getTimeSectionText = (trigger: WorkflowTriggerEvents, t: TFunction) => {
8181
};
8282

8383
export default function WorkflowStepContainer(props: WorkflowStepProps) {
84-
const { t } = useLocale();
84+
const { t, i18n } = useLocale();
8585
const utils = trpc.useUtils();
8686

8787
const { step, form, reload, setReload, teamId } = props;
@@ -145,13 +145,14 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
145145
whatsappReminderTemplate(true, action, timeFormat)
146146
);
147147
} else {
148-
const reminderBodyTemplate = emailReminderTemplate(true, action, timeFormat).emailBody;
148+
const reminderBodyTemplate = emailReminderTemplate(true, i18n.language, action, timeFormat).emailBody;
149149
form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, reminderBodyTemplate);
150150
}
151151
}
152152
if (!form.getValues(`steps.${step.stepNumber - 1}.emailSubject`)) {
153153
const subjectTemplate = emailReminderTemplate(
154154
true,
155+
i18n.language,
155156
form.getValues(`steps.${step.stepNumber - 1}.action`),
156157
timeFormat
157158
).emailSubject;
@@ -525,6 +526,7 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
525526
} else {
526527
const emailReminderBody = emailReminderTemplate(
527528
true,
529+
i18n.language,
528530
val.value,
529531
timeFormat
530532
);
@@ -832,11 +834,11 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) {
832834
} else {
833835
form.setValue(
834836
`steps.${step.stepNumber - 1}.reminderBody`,
835-
emailReminderTemplate(true, action, timeFormat).emailBody
837+
emailReminderTemplate(true, i18n.language, action, timeFormat).emailBody
836838
);
837839
form.setValue(
838840
`steps.${step.stepNumber - 1}.emailSubject`,
839-
emailReminderTemplate(true, action, timeFormat).emailSubject
841+
emailReminderTemplate(true, i18n.language, action, timeFormat).emailSubject
840842
);
841843
}
842844
} else if (val.value === WorkflowTemplates.RATING) {

‎packages/features/ee/workflows/lib/reminders/emailReminderManager.ts

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) =>
185185
} else if (template === WorkflowTemplates.REMINDER) {
186186
emailContent = emailReminderTemplate(
187187
false,
188+
evt.organizer.language.locale,
188189
action,
189190
evt.organizer.timeFormat,
190191
startTime,

‎packages/features/ee/workflows/lib/reminders/templates/emailReminderTemplate.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { WorkflowActions } from "@calcom/prisma/enums";
55

66
const emailReminderTemplate = (
77
isEditingMode: boolean,
8+
locale: string,
89
action?: WorkflowActions,
910
timeFormat?: TimeFormat,
1011
startTime?: string,
@@ -28,9 +29,9 @@ const emailReminderTemplate = (
2829
name = action === WorkflowActions.EMAIL_ATTENDEE ? "{ATTENDEE}" : "{ORGANIZER}";
2930
eventDate = `{EVENT_DATE_${dateTimeFormat}}`;
3031
} else {
31-
eventDate = dayjs(startTime).tz(timeZone).format(dateTimeFormat);
32+
eventDate = dayjs(startTime).tz(timeZone).locale(locale).format(dateTimeFormat);
3233

33-
endTime = dayjs(endTime).tz(timeZone).format(currentTimeFormat);
34+
endTime = dayjs(endTime).tz(timeZone).locale(locale).format(currentTimeFormat);
3435
}
3536

3637
const emailSubject = `Reminder: ${eventName} - ${eventDate}`;

‎packages/trpc/server/routers/viewer/workflows/create.handler.ts

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
6868

6969
const renderedEmailTemplate = emailReminderTemplate(
7070
true,
71+
ctx.user.locale,
7172
WorkflowActions.EMAIL_ATTENDEE,
7273
getTimeFormatStringFromUserTimeFormat(ctx.user.timeFormat)
7374
);

0 commit comments

Comments
 (0)