import Head from "next/head"; import prisma from "../../lib/prisma"; import { getSession, useSession } from "next-auth/client"; import Shell from "../../components/Shell"; export default function Bookings({ bookings }) { const [, loading] = useSession(); if (loading) { return

Loading...

; } return (
Bookings | Calendso
{/* */} {bookings.map((booking) => ( {/* */} ))}
Person Event Date Actions
{booking.attendees[0].name}
{booking.attendees[0].email}
{booking.title}
{booking.description}
{dayjs(booking.startTime).format("D MMMM YYYY HH:mm")}
Reschedule Cancel
); } export async function getServerSideProps(context) { const session = await getSession(context); if (!session) { return { redirect: { permanent: false, destination: "/auth/login" } }; } const user = await prisma.user.findFirst({ where: { email: session.user.email, }, select: { id: true, }, }); const bookings = await prisma.booking.findMany({ where: { userId: user.id, }, select: { uid: true, title: true, description: true, attendees: true, }, orderBy: { startTime: "desc", }, }); return { props: { bookings } }; }