From ff74822c48546c8015023b261fa7774972b556a5 Mon Sep 17 00:00:00 2001 From: Nafees Nazik <84864519+G3root@users.noreply.github.com> Date: Wed, 17 May 2023 13:47:09 +0530 Subject: [PATCH] Fix: locale and time format in attendee email (#8941) * feat: add locale prop * feat: add locale prop * feat: add locale prop * fix: time format --- packages/emails/src/components/WhenInfo.tsx | 14 +++++++++----- .../src/templates/AttendeeScheduledEmail.tsx | 8 +++++++- .../emails/src/templates/BaseScheduledEmail.tsx | 9 +++++++-- .../src/templates/BrokenIntegrationEmail.tsx | 10 +++++++++- .../emails/src/templates/NoShowFeeChargedEmail.tsx | 4 ++++ .../src/templates/OrganizerScheduledEmail.tsx | 5 +++++ 6 files changed, 41 insertions(+), 9 deletions(-) diff --git a/packages/emails/src/components/WhenInfo.tsx b/packages/emails/src/components/WhenInfo.tsx index 6effa922fb..10ba32d9de 100644 --- a/packages/emails/src/components/WhenInfo.tsx +++ b/packages/emails/src/components/WhenInfo.tsx @@ -5,7 +5,7 @@ import dayjs from "@calcom/dayjs"; // TODO: Use browser locale, implement Intl in Dayjs maybe? import "@calcom/dayjs/locales"; import { getEveryFreqFor } from "@calcom/lib/recurringStrings"; -import { TimeFormat } from "@calcom/lib/timeFormat"; +import type { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import type { RecurringEvent } from "@calcom/types/Calendar"; @@ -31,10 +31,14 @@ export function getRecurringWhen({ return ""; } -export function WhenInfo(props: { calEvent: CalendarEvent; timeZone: string; t: TFunction }) { - const { timeZone, t, calEvent: { recurringEvent } = {} } = props; - const timeFormat = props.calEvent.organizer.timeFormat || TimeFormat.TWELVE_HOUR; - const locale = props.calEvent.organizer.language.locale; +export function WhenInfo(props: { + calEvent: CalendarEvent; + timeZone: string; + t: TFunction; + locale: string; + timeFormat: TimeFormat; +}) { + const { timeZone, t, calEvent: { recurringEvent } = {}, locale, timeFormat } = props; function getRecipientStart(format: string) { return dayjs(props.calEvent.startTime).tz(timeZone).locale(locale).format(format); diff --git a/packages/emails/src/templates/AttendeeScheduledEmail.tsx b/packages/emails/src/templates/AttendeeScheduledEmail.tsx index cbb1826499..b1497cd3f9 100644 --- a/packages/emails/src/templates/AttendeeScheduledEmail.tsx +++ b/packages/emails/src/templates/AttendeeScheduledEmail.tsx @@ -9,6 +9,12 @@ export const AttendeeScheduledEmail = ( } & Partial> ) => { return ( - + ); }; diff --git a/packages/emails/src/templates/BaseScheduledEmail.tsx b/packages/emails/src/templates/BaseScheduledEmail.tsx index 94c55560d9..e54222418f 100644 --- a/packages/emails/src/templates/BaseScheduledEmail.tsx +++ b/packages/emails/src/templates/BaseScheduledEmail.tsx @@ -1,6 +1,7 @@ import type { TFunction } from "next-i18next"; import dayjs from "@calcom/dayjs"; +import { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { @@ -21,9 +22,13 @@ export const BaseScheduledEmail = ( timeZone: string; includeAppsStatus?: boolean; t: TFunction; + locale: string; + timeFormat: TimeFormat | undefined; } & Partial> ) => { - const { t, timeZone } = props; + const { t, timeZone, locale, timeFormat: timeFormat_ } = props; + + const timeFormat = timeFormat_ ?? TimeFormat.TWELVE_HOUR; function getRecipientStart(format: string) { return dayjs(props.calEvent.startTime).tz(timeZone).format(format); @@ -73,7 +78,7 @@ export const BaseScheduledEmail = ( )} - + diff --git a/packages/emails/src/templates/BrokenIntegrationEmail.tsx b/packages/emails/src/templates/BrokenIntegrationEmail.tsx index 01d0ec4808..99f7fe72ce 100644 --- a/packages/emails/src/templates/BrokenIntegrationEmail.tsx +++ b/packages/emails/src/templates/BrokenIntegrationEmail.tsx @@ -1,4 +1,4 @@ -import { TFunction } from "next-i18next"; +import type { TFunction } from "next-i18next"; import { Trans } from "react-i18next"; import { AppStoreLocationType } from "@calcom/app-store/locations"; @@ -56,6 +56,8 @@ export const BrokenIntegrationEmail = ( ) => { const { calEvent, type } = props; const t = calEvent.organizer.language.translate; + const locale = calEvent.organizer.language.locale; + const timeFormat = calEvent.organizer?.timeFormat; if (type === "video") { let location = calEvent.location ? getEnumKeyByEnumValue(AppStoreLocationType, calEvent.location) : " "; @@ -70,6 +72,8 @@ export const BrokenIntegrationEmail = ( } @@ -94,6 +98,8 @@ export const BrokenIntegrationEmail = ( } @@ -107,6 +113,8 @@ export const BrokenIntegrationEmail = ( { const { calEvent } = props; const t = props.attendee.language.translate; + const locale = props.attendee.language.locale; + const timeFormat = props.attendee?.timeFormat; if (!calEvent.paymentInfo?.amount) throw new Error("No payment info"); return ( {t("no_show_fee_charged_subtitle", { diff --git a/packages/emails/src/templates/OrganizerScheduledEmail.tsx b/packages/emails/src/templates/OrganizerScheduledEmail.tsx index fc3eab435f..d2ec9dcc22 100644 --- a/packages/emails/src/templates/OrganizerScheduledEmail.tsx +++ b/packages/emails/src/templates/OrganizerScheduledEmail.tsx @@ -29,13 +29,18 @@ export const OrganizerScheduledEmail = ( } const t = props.teamMember?.language.translate || props.calEvent.organizer.language.translate; + const locale = props.teamMember?.language.locale || props.calEvent.organizer.language.locale; + const timeFormat = props.teamMember?.timeFormat || props.calEvent.organizer?.timeFormat; + return ( {props.attendeeCancelled