fix: Hotfix-bookings list breaks on unsupported timezone (#10225)
* Adds a check for supportedTimezone values * adds timezone support check for attendeespull/10229/head
parent
da5d90eb07
commit
89f645c450
|
@ -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's
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue