Scheduling infrastructure for absolutely everyone.
fix: Hotfix-bookings list breaks on unsupported timezone (#10225)
Syed Ali Shahbaz89f645c4507b
diff --git a/packages/lib/date-fns/index.ts b/packages/lib/date-fns/index.tsindex 9f92f7b7dcb..446ca7ec352 100644--- a/packages/lib/date-fns/index.ts+++ b/packages/lib/date-fns/index.ts@@ -30,6 +30,23 @@ export const formatTime = (: dayjs(date).format(timeFormat === 12 ? "h:mma" : "HH:mm");};+/**+ * Checks if a provided timeZone string is recognized as a valid timezone by dayjs.+ *+ * @param {string} timeZone - The timezone string to be verified.+ * @returns {boolean} - Returns 'true' if the provided timezone string is recognized as a valid timezone by dayjs. Otherwise, returns 'false'.+ *+ */+export const isSupportedTimeZone = (timeZone: string) => {+ try {+ dayjs().tz(timeZone);+ return true;+ } catch (error) {+ return false;+ }+};++/*** Returns a localized and translated date or time, based on the native* Intl.DateTimeFormat available to JS. Undefined values mean the browser'sdiff --git a/packages/ui/components/popover/MeetingTimeInTimezones.tsx b/packages/ui/components/popover/MeetingTimeInTimezones.tsxindex 9069966786a..cac9cfc385f 100644--- a/packages/ui/components/popover/MeetingTimeInTimezones.tsx+++ b/packages/ui/components/popover/MeetingTimeInTimezones.tsx@@ -5,6 +5,7 @@ import {isNextDayInTimezone,isPreviousDayInTimezone,sortByTimezone,+ isSupportedTimeZone,} from "@calcom/lib/date-fns";import { Globe } from "../icon";@@ -34,8 +35,12 @@ const MeetingTimeInTimezones = ({endTime,}: MeetingTimeInTimezonesProps) => {if (!userTimezone || !attendees.length) return null;-- const attendeeTimezones = attendees.map((attendee) => attendee.timeZone);++ // If attendeeTimezone is unsupported, we fallback to host timezone. Unsupported Attendee timezone can be used due to bad API booking request in the past | backward-compatibility++ const attendeeTimezones = attendees.map((attendee) => {+ return isSupportedTimeZone(attendee.timeZone) ? attendee.timeZone : userTimezone;+ });const uniqueTimezones = [userTimezone, ...attendeeTimezones].filter((value, index, self) => self.indexOf(value) === index);