Added date and time to booking entries
This commit is contained in:
parent
e734b5f5de
commit
5388ea0610
1 changed files with 21 additions and 9 deletions
|
@ -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();
|
||||||
|
@ -49,11 +51,12 @@ export default function Bookings({ bookings }) {
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
Event
|
Event
|
||||||
</th>
|
</th>
|
||||||
{/* <th
|
<th
|
||||||
scope="col"
|
scope="col"
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
Date
|
Date
|
||||||
</th> */}
|
</th>
|
||||||
|
{console.log(bookings)}
|
||||||
<th scope="col" className="relative px-6 py-3">
|
<th scope="col" className="relative px-6 py-3">
|
||||||
<span className="sr-only">Actions</span>
|
<span className="sr-only">Actions</span>
|
||||||
</th>
|
</th>
|
||||||
|
@ -86,11 +89,14 @@ export default function Bookings({ bookings }) {
|
||||||
<div className="text-sm text-gray-900">{booking.title}</div>
|
<div className="text-sm text-gray-900">{booking.title}</div>
|
||||||
<div className="text-sm text-gray-500">{booking.description}</div>
|
<div className="text-sm text-gray-500">{booking.description}</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 && (
|
||||||
<>
|
<>
|
||||||
|
@ -153,7 +159,7 @@ export async function getServerSideProps(context) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const bookings = await prisma.booking.findMany({
|
let b = await prisma.booking.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
},
|
},
|
||||||
|
@ -165,11 +171,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 a new issue