diff --git a/pages/cancel/[uid].tsx b/pages/cancel/[uid].tsx new file mode 100644 index 00000000..8235c8df --- /dev/null +++ b/pages/cancel/[uid].tsx @@ -0,0 +1,154 @@ +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 isBetween from 'dayjs/plugin/isBetween'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; + +dayjs.extend(isSameOrBefore); +dayjs.extend(isBetween); +dayjs.extend(utc); +dayjs.extend(timezone); + +function classNames(...classes) { + return classes.filter(Boolean).join(' ') +} + +export default function Type(props) { + // Get router variables + const router = useRouter(); + + const [is24h, setIs24h] = useState(false); + + return ( +
+ + + Cancel {props.booking.title} | {props.user.name || props.user.username} | + Calendso + + + +
+
+
+ +
+
+
+
+ ); +} + +export async function getServerSideProps(context) { + const user = await prisma.user.findFirst({ + where: { + username: context.query.user, + }, + select: { + id: true, + username: true, + name: true, + } + }); + + if (!user) { + return { + notFound: true, + } + } + + const eventType = await prisma.eventType.findFirst({ + where: { + userId: user.id, + slug: { + equals: context.query.type, + }, + }, + select: { + id: true, + title: true, + description: true, + length: true + } + }); + + const booking = await prisma.booking.findFirst({ + where: { + uid: context.query.uid, + }, + select: { + id: true, + title: true, + description: true, + startTime: true, + endTime: true, + attendees: true + } + }); + + // 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(), + endTime: booking.endTime.toString() + }); + + return { + props: { + user, + eventType, + booking: bookingObj + }, + } +}