import { CalendarIcon, XIcon } from "@heroicons/react/outline"; import { ArrowRightIcon } from "@heroicons/react/solid"; import { NextPageContext } from "next"; import { getSession } from "next-auth/react"; import { useRouter } from "next/router"; import { useEffect } from "react"; import dayjs from "@calcom/dayjs"; import prisma, { bookingMinimalSelect } from "@calcom/prisma"; import Button from "@calcom/ui/Button"; import { detectBrowserTimeFormat } from "@lib/timeFormat"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import { HeadSeo } from "@components/seo/head-seo"; export default function MeetingUnavailable(props: inferSSRProps) { const router = useRouter(); // if no booking redirectis to the 404 page const emptyBooking = props.booking === null; useEffect(() => { if (emptyBooking) { router.push("/video/no-meeting-found"); } }); if (!emptyBooking) { return (
); } return null; } export async function getServerSideProps(context: NextPageContext) { const booking = await prisma.booking.findUnique({ where: { uid: context.query.uid as string, }, select: { ...bookingMinimalSelect, uid: true, user: { select: { credentials: true, }, }, dailyRef: { select: { dailyurl: true, dailytoken: true, }, }, references: { select: { uid: true, type: true, }, }, }, }); if (!booking) { // TODO: Booking is already cancelled return { props: { booking: null }, }; } const bookingObj = Object.assign({}, booking, { startTime: booking.startTime.toString(), endTime: booking.endTime.toString(), }); const session = await getSession(); return { props: { booking: bookingObj, session: session, }, }; }