
* Init dev * UI changes for recurring event + prisma * Revisiting schema + changes WIP * UI done, BE WIP * Feature completion * Unused query param removed * Invalid comment removed * Removed unused translation * Update apps/web/public/static/locales/en/common.json Thanks! Co-authored-by: Peer Richelsen <peeroke@gmail.com> * Success page changes * More progress * Email text tweaks + test + seed * Tweaking emails + Cal Apps support WIP * No app integration for now Final email and pages tweaks to avoid recurring info showed * Missing comment for clarity * Yet again, comment * Last minute fix * Missing tooltip for upcoming bookings * Fixing seed * Fixing import * Increasing timeout for e2e * Fixing any * Apply suggestions from code review Co-authored-by: Omar López <zomars@me.com> * Update apps/web/pages/d/[link]/book.tsx Co-authored-by: Omar López <zomars@me.com> * Code improvements * More code improvements * Reverting back number input arrows * Update BookingPage.tsx * Update BookingPage.tsx * Adds fallback for sendOrganizerPaymentRefundFailedEmail * Type overkill * Type fixes * Type fixes * Nitpicks * Update success.tsx * Update success.tsx * Update success.tsx * Fixing types Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Omar López <zomars@me.com>
123 lines
3.6 KiB
TypeScript
123 lines
3.6 KiB
TypeScript
import { Prisma } from "@prisma/client";
|
|
import { GetServerSidePropsContext } from "next";
|
|
import { JSONObject } from "superjson/dist/types";
|
|
|
|
import { getLocationLabels } from "@calcom/app-store/utils";
|
|
import { RecurringEvent } from "@calcom/types/Calendar";
|
|
|
|
import { asStringOrThrow, asStringOrNull } from "@lib/asStringOrNull";
|
|
import getBooking, { GetBookingType } from "@lib/getBooking";
|
|
import prisma from "@lib/prisma";
|
|
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
|
|
import BookingPage from "@components/booking/pages/BookingPage";
|
|
|
|
import { getTranslation } from "@server/lib/i18n";
|
|
|
|
export type TeamBookingPageProps = inferSSRProps<typeof getServerSideProps>;
|
|
|
|
export default function TeamBookingPage(props: TeamBookingPageProps) {
|
|
return <BookingPage {...props} />;
|
|
}
|
|
|
|
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
|
const eventTypeId = parseInt(asStringOrThrow(context.query.type));
|
|
const recurringEventCountQuery = asStringOrNull(context.query.count);
|
|
if (typeof eventTypeId !== "number" || eventTypeId % 1 !== 0) {
|
|
return {
|
|
notFound: true,
|
|
} as const;
|
|
}
|
|
|
|
const eventTypeRaw = await prisma.eventType.findUnique({
|
|
where: {
|
|
id: eventTypeId,
|
|
},
|
|
select: {
|
|
id: true,
|
|
title: true,
|
|
slug: true,
|
|
description: true,
|
|
length: true,
|
|
locations: true,
|
|
customInputs: true,
|
|
periodType: true,
|
|
periodDays: true,
|
|
periodStartDate: true,
|
|
periodEndDate: true,
|
|
periodCountCalendarDays: true,
|
|
recurringEvent: true,
|
|
disableGuests: true,
|
|
price: true,
|
|
currency: true,
|
|
metadata: true,
|
|
team: {
|
|
select: {
|
|
slug: true,
|
|
name: true,
|
|
logo: true,
|
|
},
|
|
},
|
|
users: {
|
|
select: {
|
|
id: true,
|
|
avatar: true,
|
|
name: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!eventTypeRaw) return { notFound: true };
|
|
|
|
const eventType = {
|
|
...eventTypeRaw,
|
|
recurringEvent: (eventTypeRaw.recurringEvent || {}) as RecurringEvent,
|
|
};
|
|
|
|
const eventTypeObject = [eventType].map((e) => {
|
|
return {
|
|
...e,
|
|
metadata: (eventType.metadata || {}) as JSONObject,
|
|
periodStartDate: e.periodStartDate?.toString() ?? null,
|
|
periodEndDate: e.periodEndDate?.toString() ?? null,
|
|
};
|
|
})[0];
|
|
|
|
let booking: GetBookingType | null = null;
|
|
if (context.query.rescheduleUid) {
|
|
booking = await getBooking(prisma, context.query.rescheduleUid as string);
|
|
}
|
|
|
|
const t = await getTranslation(context.locale ?? "en", "common");
|
|
|
|
// Checking if number of recurring event ocurrances is valid against event type configuration
|
|
const recurringEventCount =
|
|
(eventType.recurringEvent?.count &&
|
|
recurringEventCountQuery &&
|
|
(parseInt(recurringEventCountQuery) <= eventType.recurringEvent.count
|
|
? recurringEventCountQuery
|
|
: eventType.recurringEvent.count)) ||
|
|
null;
|
|
|
|
return {
|
|
props: {
|
|
locationLabels: getLocationLabels(t),
|
|
profile: {
|
|
...eventTypeObject.team,
|
|
slug: "team/" + eventTypeObject.slug,
|
|
image: eventTypeObject.team?.logo || null,
|
|
theme: null /* Teams don't have a theme, and `BookingPage` uses it */,
|
|
brandColor: null /* Teams don't have a brandColor, and `BookingPage` uses it */,
|
|
darkBrandColor: null /* Teams don't have a darkBrandColor, and `BookingPage` uses it */,
|
|
eventName: null,
|
|
},
|
|
eventType: eventTypeObject,
|
|
recurringEventCount,
|
|
booking,
|
|
isDynamicGroupBooking: false,
|
|
hasHashedBookingLink: false,
|
|
hashedLink: null,
|
|
},
|
|
};
|
|
}
|