calcom/pages/reschedule/[uid].tsx
Omar López 85d7122e43
Fixes Apple Calendar onboarding and type fixes (#988)
* Type fixes

* Type fixes

* Attemp to prevent unknown error in prod

* Type fixes

* Type fixes for onboarding

* Extracts ConnectIntegration

* Extracts IntegrationListItem

* Extracts CalendarsList

* Uses CalendarList on onboarding

* Removes deprecated Alert

* Extracts DisconnectIntegration

* Extracts CalendarSwitch

* Extracts ConnectedCalendarsList

* Extracted connectedCalendar logic for reuse

* Extracted SubHeadingTitleWithConnections

* Type fixes

* Fetched connected calendars in onboarding

* Refreshes data on when adding/removing calendars on onboarding

* Removed testing code

* Type fixes

* Feedback

* Moved integration helpers

* I was sleepy

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-10-20 15:42:40 +00:00

59 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 || "rick") /* This shouldn't happen */ +
"/" +
booking.eventType.slug;
return {
redirect: {
destination: "/" + eventPage + "?rescheduleUid=" + context.query.uid,
permanent: false,
},
};
}