2021-08-19 12:27:01 +00:00
|
|
|
import { GetServerSidePropsContext } from "next";
|
|
|
|
import prisma from "../../lib/prisma";
|
2021-06-09 18:28:39 +00:00
|
|
|
|
2021-08-19 12:27:01 +00:00
|
|
|
export default function Type() {
|
|
|
|
// Just redirect to the schedule page to reschedule it.
|
|
|
|
return null;
|
2021-06-09 18:28:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-19 12:27:01 +00:00
|
|
|
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|
|
|
const booking = await prisma.booking.findFirst({
|
|
|
|
where: {
|
|
|
|
uid: context.query.uid as string,
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
user: { select: { username: true } },
|
|
|
|
eventType: { select: { slug: true } },
|
|
|
|
title: true,
|
|
|
|
description: true,
|
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
|
|
|
attendees: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (!booking?.user || !booking.eventType) {
|
2021-06-09 18:28:39 +00:00
|
|
|
return {
|
2021-08-19 12:27:01 +00:00
|
|
|
notFound: true,
|
2021-09-08 11:03:43 +00:00
|
|
|
};
|
2021-08-19 12:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
redirect: {
|
|
|
|
destination:
|
|
|
|
"/" + booking.user.username + "/" + booking.eventType.slug + "?rescheduleUid=" + context.query.uid,
|
|
|
|
permanent: false,
|
|
|
|
},
|
|
|
|
};
|
2021-06-09 18:28:39 +00:00
|
|
|
}
|