Merge pull request #404 from alishaz-polymath/main
CAL-206 Added date and time to /booking entriespull/406/head
commit
509206e85f
|
@ -3,6 +3,8 @@ import prisma from "../../lib/prisma";
|
||||||
import { getSession, useSession } from "next-auth/client";
|
import { getSession, useSession } from "next-auth/client";
|
||||||
import Shell from "../../components/Shell";
|
import Shell from "../../components/Shell";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
|
||||||
export default function Bookings({ bookings }) {
|
export default function Bookings({ bookings }) {
|
||||||
const [, loading] = useSession();
|
const [, loading] = useSession();
|
||||||
|
@ -37,6 +39,28 @@ export default function Bookings({ bookings }) {
|
||||||
<div className="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
|
<div className="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
|
||||||
<div className="shadow overflow-hidden border-b border-gray-200 sm:rounded-sm">
|
<div className="shadow overflow-hidden border-b border-gray-200 sm:rounded-sm">
|
||||||
<table className="min-w-full divide-y divide-gray-200">
|
<table className="min-w-full divide-y divide-gray-200">
|
||||||
|
<thead className="bg-gray-50">
|
||||||
|
<tr>
|
||||||
|
<th
|
||||||
|
scope="col"
|
||||||
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
|
Person
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
scope="col"
|
||||||
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
|
Event
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
scope="col"
|
||||||
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
|
Date
|
||||||
|
</th>
|
||||||
|
<th scope="col" className="relative px-6 py-3">
|
||||||
|
<span className="sr-only">Actions</span>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
<tbody className="bg-white divide-y divide-gray-200">
|
<tbody className="bg-white divide-y divide-gray-200">
|
||||||
{bookings
|
{bookings
|
||||||
.filter((booking) => !booking.confirmed && !booking.rejected)
|
.filter((booking) => !booking.confirmed && !booking.rejected)
|
||||||
|
@ -70,11 +94,14 @@ export default function Bookings({ bookings }) {
|
||||||
You and {booking.attendees[0].name}
|
You and {booking.attendees[0].name}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
{/* <td className="px-6 py-4 whitespace-nowrap">
|
<td className="px-6 py-4 whitespace-nowrap">
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-900">
|
||||||
{dayjs(booking.startTime).format("D MMMM YYYY HH:mm")}
|
{dayjs(booking.startTime).format("D MMMM YYYY")}
|
||||||
</div>
|
</div>
|
||||||
</td> */}
|
<div className="text-sm text-gray-500">
|
||||||
|
{dayjs(booking.startTime).format("HH:mm")} - {dayjs(booking.endTime).format("HH:mm")}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||||
{!booking.confirmed && !booking.rejected && (
|
{!booking.confirmed && !booking.rejected && (
|
||||||
<>
|
<>
|
||||||
|
@ -137,7 +164,7 @@ export async function getServerSideProps(context) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const bookings = await prisma.booking.findMany({
|
const b = await prisma.booking.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
},
|
},
|
||||||
|
@ -149,11 +176,17 @@ export async function getServerSideProps(context) {
|
||||||
confirmed: true,
|
confirmed: true,
|
||||||
rejected: true,
|
rejected: true,
|
||||||
id: true,
|
id: true,
|
||||||
|
startTime: true,
|
||||||
|
endTime: true,
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
startTime: "desc",
|
startTime: "asc",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const bookings = b.map(booking=>{
|
||||||
|
return ({...booking, startTime:booking.startTime.toISOString(), endTime:booking.endTime.toISOString(),})
|
||||||
|
});
|
||||||
|
|
||||||
return { props: { bookings } };
|
return { props: { bookings } };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue