calcom/pages/reschedule/[uid].tsx
Omar López a04336ba06
Added booking tabs, type fixing and refactoring (#825)
* More type fixes

* More type fixes

* Type fixes

* Adds inputMode to email fields

* Added booking tabs

* Adds aditional notes to bookings
2021-09-29 22:33:18 +01:00

55 lines
1.3 KiB
TypeScript

import { GetServerSidePropsContext } from "next";
import { asStringOrUndefined } from "@lib/asStringOrNull";
import prisma from "@lib/prisma";
export default function Type() {
// Just redirect to the schedule page to reschedule it.
return null;
}
export async function getServerSideProps(context: GetServerSidePropsContext) {
const booking = await prisma.booking.findUnique({
where: {
uid: asStringOrUndefined(context.query.uid),
},
select: {
id: true,
eventType: {
select: {
users: {
select: {
username: true,
},
},
slug: true,
team: {
select: {
slug: true,
},
},
},
},
user: true,
title: true,
description: true,
startTime: true,
endTime: true,
attendees: true,
},
});
if (!booking?.eventType) throw Error("This booking doesn't exists");
const eventType = booking.eventType;
const eventPage =
(eventType.team ? "team/" + eventType.team.slug : booking.user.username) + "/" + booking.eventType.slug;
return {
redirect: {
destination: "/" + eventPage + "?rescheduleUid=" + context.query.uid,
permanent: false,
},
};
}