import Head from "next/head"; import prisma from "../../lib/prisma"; import { getSession, useSession } from "next-auth/client"; import Shell from "../../components/Shell"; import { useRouter } from "next/router"; import dayjs from "dayjs"; import { Fragment } from "react"; import { Menu, Transition } from "@headlessui/react"; import { DotsHorizontalIcon } from "@heroicons/react/solid"; import classNames from "@lib/classNames"; export default function Bookings({ bookings }) { const [, loading] = useSession(); const router = useRouter(); if (loading) { return
Loading...
; } async function confirmBookingHandler(booking, confirm: boolean) { const res = await fetch("/api/book/confirm", { method: "PATCH", body: JSON.stringify({ id: booking.id, confirmed: confirm }), headers: { "Content-Type": "application/json", }, }); if (res.ok) { await router.replace(router.asPath); } } return (Event | Date | Actions |
---|---|---|
{!booking.confirmed && !booking.rejected && (
Unconfirmed
)}
{booking.title}
{booking.attendees[0].email}
|
{dayjs(booking.startTime).format("D MMMM YYYY")}
{dayjs(booking.startTime).format("HH:mm")} -{" "}
{dayjs(booking.endTime).format("HH:mm")}
|
{!booking.confirmed && !booking.rejected && (
<>
>
)}
{booking.confirmed && !booking.rejected && (
<>
Cancel
Reschedule
>
)}
{!booking.confirmed && booking.rejected && (
Rejected
)}
|