diff --git a/pages/cancel/[uid].tsx b/pages/cancel/[uid].tsx index 06af00d123..2e9d1fa5f7 100644 --- a/pages/cancel/[uid].tsx +++ b/pages/cancel/[uid].tsx @@ -1,13 +1,13 @@ -import { useState } from "react"; -import Head from "next/head"; -import prisma from "../../lib/prisma"; -import { useRouter } from "next/router"; -import dayjs from "dayjs"; import { CalendarIcon, ClockIcon, XIcon } from "@heroicons/react/solid"; -import isSameOrBefore from "dayjs/plugin/isSameOrBefore"; +import dayjs from "dayjs"; import isBetween from "dayjs/plugin/isBetween"; -import utc from "dayjs/plugin/utc"; +import isSameOrBefore from "dayjs/plugin/isSameOrBefore"; import timezone from "dayjs/plugin/timezone"; +import utc from "dayjs/plugin/utc"; +import Head from "next/head"; +import { useRouter } from "next/router"; +import { useState } from "react"; +import prisma from "../../lib/prisma"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "../../lib/telemetry"; dayjs.extend(isSameOrBefore); @@ -23,7 +23,7 @@ export default function Type(props) { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [is24h, setIs24h] = useState(false); const [loading, setLoading] = useState(false); - const [error, setError] = useState(null); + const [error, setError] = useState(props.booking ? null : "This booking was already cancelled"); const telemetry = useTelemetry(); // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -57,7 +57,8 @@ export default function Type(props) {
- Cancel {props.booking.title} | {props.user.name || props.user.username} | Calendso + Cancel {props.booking && `${props.booking.title} | ${props.user.name || props.user.username} `}| + Calendso @@ -86,51 +87,53 @@ export default function Type(props) {
)} {!error && ( -
-
- -
-
- -
-

Instead, you could also reschedule it.

+ <> +
+
+
-
-

{props.booking.title}

-

- - {props.eventType.length} minutes -

-

- - {dayjs - .utc(props.booking.startTime) - .format((is24h ? "H:mm" : "h:mma") + ", dddd DD MMMM YYYY")} -

+
+ +
+

Instead, you could also reschedule it.

+
+
+

{props.booking.title}

+

+ + {props.eventType.length} minutes +

+

+ + {dayjs + .utc(props.booking.startTime) + .format((is24h ? "H:mm" : "h:mma") + ", dddd DD MMMM YYYY")} +

+
-
+
+
+ + +
+
+ )} -
-
- - -
-
@@ -163,6 +166,12 @@ export async function getServerSideProps(context) { }, }); + if (!booking) { + return { + props: { booking: null }, + }; + } + // Workaround since Next.js has problems serializing date objects (see https://github.com/vercel/next.js/issues/11993) const bookingObj = Object.assign({}, booking, { startTime: booking.startTime.toString(),