cal.pub0.org/pages/reschedule/[uid].tsx

39 lines
917 B
TypeScript
Raw Normal View History

import { GetServerSidePropsContext } from "next";
import prisma from "../../lib/prisma";
2021-06-09 18:28:39 +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
}
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 {
notFound: true,
};
}
return {
redirect: {
destination:
"/" + booking.user.username + "/" + booking.eventType.slug + "?rescheduleUid=" + context.query.uid,
permanent: false,
},
};
2021-06-09 18:28:39 +00:00
}