Fix: hydration error /booking/[uid] (#7732)
parent
3924731266
commit
a57519040e
|
@ -1,5 +1,5 @@
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
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";
|
||||||
|
@ -36,6 +36,13 @@ export default function CancelBooking(props: Props) {
|
||||||
const [error, setError] = useState<string | null>(booking ? null : t("booking_already_cancelled"));
|
const [error, setError] = useState<string | null>(booking ? null : t("booking_already_cancelled"));
|
||||||
useTheme(props.theme);
|
useTheme(props.theme);
|
||||||
|
|
||||||
|
const cancelBookingRef = useCallback((node: HTMLTextAreaElement) => {
|
||||||
|
if (node !== null) {
|
||||||
|
node.scrollIntoView({ behavior: "smooth" });
|
||||||
|
node.focus();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{error && (
|
{error && (
|
||||||
|
@ -54,6 +61,7 @@ export default function CancelBooking(props: Props) {
|
||||||
<div className="mt-5 sm:mt-6">
|
<div className="mt-5 sm:mt-6">
|
||||||
<label className="text-bookingdark font-medium dark:text-white">{t("cancellation_reason")}</label>
|
<label className="text-bookingdark font-medium dark:text-white">{t("cancellation_reason")}</label>
|
||||||
<TextArea
|
<TextArea
|
||||||
|
ref={cancelBookingRef}
|
||||||
placeholder={t("cancellation_reason_placeholder")}
|
placeholder={t("cancellation_reason_placeholder")}
|
||||||
value={cancellationReason}
|
value={cancellationReason}
|
||||||
onChange={(e) => setCancellationReason(e.target.value)}
|
onChange={(e) => setCancellationReason(e.target.value)}
|
||||||
|
|
|
@ -47,7 +47,7 @@ import prisma from "@calcom/prisma";
|
||||||
import type { Prisma } from "@calcom/prisma/client";
|
import type { Prisma } from "@calcom/prisma/client";
|
||||||
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
|
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||||
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
import { customInputSchema, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
|
||||||
import { Badge, Button, EmailInput, HeadSeo } from "@calcom/ui";
|
import { Button, EmailInput, HeadSeo, Badge } from "@calcom/ui";
|
||||||
import { FiX, FiExternalLink, FiChevronLeft, FiCheck, FiCalendar } from "@calcom/ui/components/icon";
|
import { FiX, FiExternalLink, FiChevronLeft, FiCheck, FiCalendar } from "@calcom/ui/components/icon";
|
||||||
|
|
||||||
import { timeZone } from "@lib/clock";
|
import { timeZone } from "@lib/clock";
|
||||||
|
@ -199,9 +199,6 @@ export default function Success(props: SuccessProps) {
|
||||||
seatReferenceUid,
|
seatReferenceUid,
|
||||||
} = querySchema.parse(router.query);
|
} = querySchema.parse(router.query);
|
||||||
|
|
||||||
if ((isCancellationMode || changes) && typeof window !== "undefined") {
|
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
|
||||||
}
|
|
||||||
const tz =
|
const tz =
|
||||||
(isSuccessBookingPage
|
(isSuccessBookingPage
|
||||||
? props.bookingInfo.attendees.find((attendee) => attendee.email === email)?.timeZone
|
? props.bookingInfo.attendees.find((attendee) => attendee.email === email)?.timeZone
|
||||||
|
@ -213,10 +210,6 @@ export default function Success(props: SuccessProps) {
|
||||||
props?.bookingInfo?.metadata || {}
|
props?.bookingInfo?.metadata || {}
|
||||||
)?.videoCallUrl;
|
)?.videoCallUrl;
|
||||||
|
|
||||||
if (!location) {
|
|
||||||
// Can't use logger.error because it throws error on client. stdout isn't available to it.
|
|
||||||
console.error(`No location found `);
|
|
||||||
}
|
|
||||||
const status = props.bookingInfo?.status;
|
const status = props.bookingInfo?.status;
|
||||||
const reschedule = props.bookingInfo.status === BookingStatus.ACCEPTED;
|
const reschedule = props.bookingInfo.status === BookingStatus.ACCEPTED;
|
||||||
const cancellationReason = props.bookingInfo.cancellationReason || props.bookingInfo.rejectionReason;
|
const cancellationReason = props.bookingInfo.cancellationReason || props.bookingInfo.rejectionReason;
|
||||||
|
@ -239,12 +232,24 @@ export default function Success(props: SuccessProps) {
|
||||||
const [calculatedDuration, setCalculatedDuration] = useState<number | undefined>(undefined);
|
const [calculatedDuration, setCalculatedDuration] = useState<number | undefined>(undefined);
|
||||||
|
|
||||||
function setIsCancellationMode(value: boolean) {
|
function setIsCancellationMode(value: boolean) {
|
||||||
if (value) router.query.cancel = "true";
|
const query_ = { ...router.query };
|
||||||
else delete router.query.cancel;
|
|
||||||
router.replace({
|
if (value) {
|
||||||
|
query_.cancel = "true";
|
||||||
|
} else {
|
||||||
|
if (query_.cancel) {
|
||||||
|
delete query_.cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
router.replace(
|
||||||
|
{
|
||||||
pathname: router.pathname,
|
pathname: router.pathname,
|
||||||
query: { ...router.query },
|
query: { ...query_ },
|
||||||
});
|
},
|
||||||
|
undefined,
|
||||||
|
{ scroll: false }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventNameObject = {
|
const eventNameObject = {
|
||||||
|
@ -514,13 +519,12 @@ export default function Success(props: SuccessProps) {
|
||||||
<>
|
<>
|
||||||
<div className="font-medium">{t("who")}</div>
|
<div className="font-medium">{t("who")}</div>
|
||||||
<div className="col-span-2 last:mb-0">
|
<div className="col-span-2 last:mb-0">
|
||||||
<>
|
|
||||||
{bookingInfo?.user && (
|
{bookingInfo?.user && (
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<p>
|
<div>
|
||||||
<span className="mr-2">{bookingInfo.user.name}</span>
|
<span className="mr-2">{bookingInfo.user.name}</span>
|
||||||
<Badge variant="blue">{t("Host")}</Badge>
|
<Badge variant="blue">{t("Host")}</Badge>
|
||||||
</p>
|
</div>
|
||||||
<p className="text-bookinglight">{bookingInfo.user.email}</p>
|
<p className="text-bookinglight">{bookingInfo.user.email}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -530,7 +534,6 @@ export default function Success(props: SuccessProps) {
|
||||||
<p className="text-bookinglight">{attendee.email}</p>
|
<p className="text-bookinglight">{attendee.email}</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue