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 [session, loading] = useSession(); if (loading) { return

Loading...

; } return (
Bookings | Calendso
{bookings.map((booking) => ( ))}
Title Description Name Email Edit
{booking.title} {booking.description} {booking.attendees[0].name} {booking.attendees[0].email} 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, }, }); return { props: { bookings } }; }