fix: Invalid time zone specified: Etc/Unknown (#18121)

* fix: Invalid time zone specified: Etc/Unknown

* update

* Update PaymentPage.tsx

* update

* update one more file

* address review

* update test

---------

Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
Anik Dhabal BabuandUdit Takkar authored and GitHub committed 2024-12-13 15:29:02 +00:00
1 parent a84513eda5
commit 645985c783
10 files changed
+30 -23

No files matched your search

+2 -3
View File
@@ -1,5 +1,5 @@
// handles logic related to user clock display using 24h display / timeZone options.
import dayjs from "@calcom/dayjs";
import { CURRENT_TIMEZONE } from "@calcom/lib/constants";
import {
getIs24hClockFromLocalStorage,
isBrowserLocale24h,
@@ -26,8 +26,7 @@ const initClock = () => {
// This only sets browser locale if there's no preference on localStorage.
if (getIs24hClockFromLocalStorage() === null) set24hClock(isBrowserLocale24h());
timeOptions.is24hClock = !!getIs24hClockFromLocalStorage();
timeOptions.inviteeTimeZone =
localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess() || "Europe/London";
timeOptions.inviteeTimeZone = localStorage.getItem("timeOption.preferredTimeZone") || CURRENT_TIMEZONE;
};
const is24h = (is24hClock?: boolean) => {
@@ -103,6 +103,13 @@ describe("Success Component", () => {
vi.mocked(useRouterQuery).mockReturnValue({
uid: "uid",
});
vi.mock("@calcom/lib/constants", async (importOriginal) => {
const actual = await importOriginal<any>();
return {
...actual,
CURRENT_TIMEZONE: "Europe/London",
};
});
vi.mocked(useSession).mockReturnValue({
update: vi.fn(),
status: "authenticated",
@@ -31,7 +31,7 @@ import {
SystemField,
TITLE_FIELD,
} from "@calcom/features/bookings/lib/SystemField";
import { APP_NAME } from "@calcom/lib/constants";
import { APP_NAME, CURRENT_TIMEZONE } from "@calcom/lib/constants";
import {
formatToLocalizedDate,
formatToLocalizedTime,
@@ -258,9 +258,7 @@ export default function Success(props: PageProps) {
}, [telemetry]); */
useEffect(() => {
setDate(
date.tz(localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess() || "Europe/London")
);
setDate(date.tz(localStorage.getItem("timeOption.preferredTimeZone") || CURRENT_TIMEZONE));
setIs24h(props?.userTimeFormat ? props.userTimeFormat === 24 : !!getIs24hClockFromLocalStorage());
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [eventType, needsConfirmation]);