import { CalendarIcon, XIcon } from "@heroicons/react/solid"; import dayjs from "dayjs"; import { GetServerSidePropsContext } from "next"; import { useRouter } from "next/router"; import { useState } from "react"; import { Button } from "@calcom/ui/Button"; import { TextField } from "@calcom/ui/form/fields"; import { asStringOrUndefined } from "@lib/asStringOrNull"; import { getSession } from "@lib/auth"; import { useLocale } from "@lib/hooks/useLocale"; import prisma from "@lib/prisma"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; import { detectBrowserTimeFormat } from "@lib/timeFormat"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import CustomBranding from "@components/CustomBranding"; import { HeadSeo } from "@components/seo/head-seo"; import { ssrInit } from "@server/lib/ssr"; export default function Type(props: inferSSRProps) { const { t } = useLocale(); // Get router variables const router = useRouter(); const { uid } = router.query; const [loading, setLoading] = useState(false); const [error, setError] = useState(props.booking ? null : t("booking_already_cancelled")); const [cancellationReason, setCancellationReason] = useState(""); const telemetry = useTelemetry(); return (
); } export const getServerSideProps = async (context: GetServerSidePropsContext) => { const ssr = await ssrInit(context); const session = await getSession(context); const booking = await prisma.booking.findUnique({ where: { uid: asStringOrUndefined(context.query.uid), }, select: { id: true, title: true, description: true, startTime: true, endTime: true, attendees: true, user: { select: { id: true, username: true, name: true, brandColor: true, darkBrandColor: true, }, }, eventType: { select: { team: { select: { slug: true, name: 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 profile = { name: booking.eventType?.team?.name || booking.user?.name || null, slug: booking.eventType?.team?.slug || booking.user?.username || null, brandColor: booking.user?.brandColor || null, darkBrandColor: booking.user?.darkBrandColor || null, }; return { props: { profile, booking: bookingObj, cancellationAllowed: (!!session?.user && session.user?.id === booking.user?.id) || booking.startTime >= new Date(), trpcState: ssr.dehydrate(), }, }; };