calcom/pages/reschedule/[uid].tsx
Alex Johansson f63aa5d550
add linting in CI + fix lint errors (#473)
* run `yarn lint --fix`

* Revert "Revert "add linting to ci""

This reverts commit 0bbbbee4be.

* Fixed some errors

* remove unused code - not sure why this was here?

* assert env var

* more type fixes

* fix typings og gcal callback - needs testing

* rename `md5.ts` to `md5.js`

it is js.

* fix types

* fix types

* fix lint errors

* fix last lint error

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2021-08-19 14:27:01 +02:00

38 lines
926 B
TypeScript

import { GetServerSidePropsContext } from "next";
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.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) {
return {
notFound: true,
} as const;
}
return {
redirect: {
destination:
"/" + booking.user.username + "/" + booking.eventType.slug + "?rescheduleUid=" + context.query.uid,
permanent: false,
},
};
}