From ebb3e87284a03ccf14d74c8408f8e8cf2279ef1c Mon Sep 17 00:00:00 2001
From: Bailey Pumfleet
Date: Thu, 24 Jun 2021 14:36:31 +0100
Subject: [PATCH] Add bookings page
---
components/Shell.tsx | 13 ++++-
pages/bookings/index.tsx | 121 +++++++++++++++++++++++++++++++++++++++
2 files changed, 131 insertions(+), 3 deletions(-)
create mode 100644 pages/bookings/index.tsx
diff --git a/components/Shell.tsx b/components/Shell.tsx
index e51ff814..57db5acc 100644
--- a/components/Shell.tsx
+++ b/components/Shell.tsx
@@ -59,9 +59,16 @@ export default function Shell(props) {
Dashboard
- {/*
- Bookings
- */}
+
+
+ Bookings
+
+
Loading...
;
+ }
+
+ return (
+
+
+
Bookings | Calendso
+
+
+
+
+
+
+
+
+
+
+
+ Title
+ |
+
+ Description
+ |
+
+ Name
+ |
+
+ Email
+ |
+
+ Edit
+ |
+
+
+
+ {bookings.map((booking) => (
+
+
+ {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 } };
+}