localStorage isnt available at server and in incognito mode
This commit is contained in:
parent
0098591a56
commit
ee84b37266
|
@ -12,6 +12,7 @@ import { WEBSITE_URL } from "@calcom/lib/constants";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import useTheme from "@calcom/lib/hooks/useTheme";
|
import useTheme from "@calcom/lib/hooks/useTheme";
|
||||||
import { getIs24hClockFromLocalStorage, isBrowserLocale24h } from "@calcom/lib/timeFormat";
|
import { getIs24hClockFromLocalStorage, isBrowserLocale24h } from "@calcom/lib/timeFormat";
|
||||||
|
import { localStorage } from "@calcom/lib/webstorage";
|
||||||
import { Icon } from "@calcom/ui/Icon";
|
import { Icon } from "@calcom/ui/Icon";
|
||||||
|
|
||||||
import type { PaymentPageProps } from "../pages/payment";
|
import type { PaymentPageProps } from "../pages/payment";
|
||||||
|
@ -21,11 +22,14 @@ const PaymentPage: FC<PaymentPageProps> = (props) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const [is24h, setIs24h] = useState(isBrowserLocale24h());
|
const [is24h, setIs24h] = useState(isBrowserLocale24h());
|
||||||
const [date, setDate] = useState(dayjs.utc(props.booking.startTime));
|
const [date, setDate] = useState(dayjs.utc(props.booking.startTime));
|
||||||
|
const [timezone, setTimezone] = useState<string | null>(null);
|
||||||
useTheme(props.profile.theme);
|
useTheme(props.profile.theme);
|
||||||
const isEmbed = useIsEmbed();
|
const isEmbed = useIsEmbed();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let embedIframeWidth = 0;
|
let embedIframeWidth = 0;
|
||||||
setDate(date.tz(localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess()));
|
const _timezone = localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess();
|
||||||
|
setTimezone(_timezone);
|
||||||
|
setDate(date.tz(_timezone));
|
||||||
setIs24h(!!getIs24hClockFromLocalStorage());
|
setIs24h(!!getIs24hClockFromLocalStorage());
|
||||||
if (isEmbed) {
|
if (isEmbed) {
|
||||||
requestAnimationFrame(function fixStripeIframe() {
|
requestAnimationFrame(function fixStripeIframe() {
|
||||||
|
@ -95,9 +99,7 @@ const PaymentPage: FC<PaymentPageProps> = (props) => {
|
||||||
{date.format("dddd, DD MMMM YYYY")}
|
{date.format("dddd, DD MMMM YYYY")}
|
||||||
<br />
|
<br />
|
||||||
{date.format(is24h ? "H:mm" : "h:mma")} - {props.eventType.length} mins{" "}
|
{date.format(is24h ? "H:mm" : "h:mma")} - {props.eventType.length} mins{" "}
|
||||||
<span className="text-gray-500">
|
<span className="text-gray-500">({timezone})</span>
|
||||||
({localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess()})
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
{props.booking.location && (
|
{props.booking.location && (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user