2023-02-16 22:39:57 +00:00
|
|
|
import type { GetServerSidePropsContext } from "next";
|
2023-03-14 04:19:05 +00:00
|
|
|
import { z } from "zod";
|
2021-03-22 13:48:48 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { LocationObject } from "@calcom/app-store/locations";
|
|
|
|
import { privacyFilteredLocations } from "@calcom/app-store/locations";
|
2023-02-15 15:42:49 +00:00
|
|
|
import { getAppFromSlug } from "@calcom/app-store/utils";
|
2023-03-14 04:19:05 +00:00
|
|
|
import dayjs from "@calcom/dayjs";
|
New Booker Component (preparations for booker atom) (#6792)
* Wip on booker atom
* Wip on booker atom
* Added correct icon imports
* Fixed build
* Responsive improvements
* Removed package lock
* Responsive tweaks
* Animation improvements and cleanup
* Animation improvements and event meta layout improvements.
* Tweaked margins.
* Added more event meta blocks
* Layout tweaks
* Converted booker layout to css grid and implemented multiple layout options
* cleanup
* Fixed build
* Fixed build
* Added temporary api route to enable/disable new booker
* Added sticky behavior
* Reverted yarn.lock and reinstalled new packages to see if this fixes build on vercel.
* Ensure divider lines always have 100% height.
* Improved animation config + initial load
* Ensure to pass eventid to getschedule, otherwise custom availability schedule wont work and wont return any availability
* Fixed divider line heights in booker
* Fixed timezone select positioning
* Added ability to view multiple days of timeslots
* Added icons to booker toggle
* Always show timeslots in timeslots view, also if no date is selected yet. In that case we show upcoming 5 days.
* Fixed timeslots in small calendar view
* Show selected day in calendar
* Fixed booker timeslots view
* Wip in making booking form work
* Moved most of the booker atom stuff to features, since it belongs there. Atom should be a rather small wrapper.
* Added create event functionality to booker form.
* Added guests toggle to booker form and styled input addons in dark mode.
* Added dynamic weekstart to booker
* Added seats limit feature to timeslots.
* Removed todo
* Added correct event avatars
* Added correct event name and icons
* Added correct translation for minutes text in multi duration
* Add rescheduling functionality to new booker.
* Added selected booking time to booking meta in sidebar.
* Abstracted away timeformat to custom hook
* Added correct key props to all components in booker.
* Fix build
* Create some new custom hooks to have a lot less repitition in code.
* Moved bookerform component inside booker directory since it is tied to it.
* Added error messages to booker form, plus fixed bug in recurring events.
* Added some comments <3
* Fixed todos in booker form.
* Added loading state for timeslot selector, and added prefetching of next month, in case of multi day view showing 2 months at the same time.
* Fixed import paths
* Added away view
* Validate uniqueness of event attendees.
* Tweaked comment
* #5798 added correct date format and style for selected date in booker.
* UI improvements
* Enable possibility to add booking values via query params.
* Added functionality to update query params when user selects date/duration etc in booker
* First steps in adding e2e test.
* Fixes after merge with main, and added new form builder.
* Implemented new form types and validation to booker, confirming new form builder. Validation still throwing wrong error keys though.
* Added search to timezone dropdown
* Added e2e test for booker (copy of current booker tests, only enabling cookie), plus fixed reschedule view.
* Updated yarn.lock
* Added new booker for team pages.
* Fixed input addon (hover) styles.
* Added dynamic booking.
* Hide timeformat select for multi day view for now.
* Cleanup and ui tweaks
* removed log
* Mobile improvements
* Cleanup
* Small design tweaks after talking to ciaran.
* Text color and weight tweaks in booker
* Added rainbow gates to new booker.
* Added in default values which fixes form vallidation (???).
* Added empty defaults for name and email
* Added metadata
* Reset yarn.lock
* Fixed booker zod validation after change in main.
* Icon tweak
* Fixed timezone select styles after new classnames have been merged.
* Updated seat availability styles.
* Update yarn.lock
* Added explanation for alchemy key to .env.example
* Added tooltip to booker month/week/multiday toggle
* Fixed timezoneselect styles in booker after select updates.
* Updates bookingfields component by taking changes from current booker component
* Removed remaining booker todos
* Fix bookeventform
* Fix for recurring event meta
* Type fixes
* Typefixes
* Team event fixes
* Avoid hydration errors by only rendering date picker client side. Remove web3 gates since we dont offer them anymore. Prevent timeslot select from staying open when switching to a different month.
* Don't show calendar on mobile booker during booking.
* Always align booker buttons to bottom
* Don't show backend messages in error, rather show a helpful text like the current booker does as well.
* Do invisible next rewrite based on cookie from next.config.js (#7949)
* Do invisible next rewrite based on cookie from next.config.js
* Name embed link instead of bookerPath
* Rewrites only dynamic user pages
---------
Co-authored-by: zomars <zomars@me.com>
* Don't allow change of timezone when bookerform is visible
* Don't add duration to query param if the event is not a multi duration event.
* Update next.config.js
* Added correct timezone formatting to event meta when timeslot is selected.
* removed .env variable that isn't needed anymore.
* Update Gates.tsx
* Type fixes
* Allows to run all tests with the new booker
* Fixed timezone select styles after merge.
* Don't throw error when event doesn't have hosts, rather return no users, which will result in no availability in UI.
* Make booker errors of severity info instead of warning.
* Ensure team avatars are shown, as well as filter on uniqueness of avatars.
* Added all booked today message to timeslots.
* Added cal.com logo to booker.
* Fixed fragment classname error, minor mobile animation tweaks plus make all booked today text smaller for multi day layout.
* Improved timezone select styles, and updated arguments of getbooking function after updates in main.
* Prevent infinite loop in rewriting new booker.
* Prevent infinite loop in rewriting new booker.
* Moved new-booker pages to their own directory to prevent regexes confusing next and thus nut running getserversideprops after rewrite. Also adding clearing of old date in booker store, that could stick around when user immediately navigates back to the same page after booking.
* Fixed cal logo color in darkmode for new booker.
* Implemented new color tokens and theme variables. Also small design tweaks after merge with main.
* Minor style tweaks
* Show multiple locations in tooltip on booker #8222
* Radio button style tweaks
* Fixed build
* Updated calendar imports to new lucide names
* Removed resetting of selected times logic, because otherwise url params wouldnt be taken into account which is actually what we want. So old values sticking around when navigating back is actually the desired behavior.
* Updated tests to instead of always run the new booker in tests, have a utility to run both the new and old booker for specified tests.
* Added comment and eslint disable for if statement in booker test.
* Update packages/features/bookings/components/event-meta/Details.tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Fix badge types
* Lazy loaded timezone select to save 85kb in bundle size.
* Upgraded framer to latest. Als moved framer and react sticky deps to features instead of atoms.
* Added new pagewrapper logic
* Simplified rescheduling ssr fetches, this now also supports multi seat rescheduling.
* Unset selected time when user is rescheduling directly after a new booking, otherwise it would show the form instead of new time selection.
* Updated form builder logic as per form builder in current booker.
* Updated form builder prefill logic as per logic in current booker.
* Updated getbooking function to fetch correct details when a reschedule uid is used
* Fixed booking questions test by NOT waiting for /book page because the new booker doesnt have this.
* Added former meeting time to reschedule view.
* Fixed types
* Undo playwright config update by mistake.
* Fixed event types test by only waiting for /book page in old booker
* Set new booker cookie to one year in the future instead of 2050
* added reset mockdate to test
* Temporary disabled test to see if this solves the out of memory error.
* Deleted test to see if that fixes the memory error
* Select first day when switching months in booker
---------
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Sean Brydon <sean@cal.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
2023-04-24 14:32:30 +00:00
|
|
|
import getBooking from "@calcom/features/bookings/lib/get-booking";
|
|
|
|
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
2023-03-02 18:15:28 +00:00
|
|
|
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
2022-06-10 00:32:34 +00:00
|
|
|
import { parseRecurringEvent } from "@calcom/lib";
|
2022-04-08 16:50:10 +00:00
|
|
|
import {
|
|
|
|
getDefaultEvent,
|
|
|
|
getDynamicEventName,
|
|
|
|
getGroupName,
|
|
|
|
getUsernameList,
|
|
|
|
} from "@calcom/lib/defaultEvents";
|
2022-04-06 17:20:30 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-03-28 09:40:13 +00:00
|
|
|
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
|
2023-03-14 04:19:05 +00:00
|
|
|
import prisma, { bookEventTypeSelect } from "@calcom/prisma";
|
2023-02-15 15:42:49 +00:00
|
|
|
import {
|
|
|
|
customInputSchema,
|
|
|
|
EventTypeMetaDataSchema,
|
|
|
|
userMetadata as userMetadataSchema,
|
|
|
|
} from "@calcom/prisma/zod-utils";
|
2022-04-05 18:03:22 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
2022-02-11 22:20:10 +00:00
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
import PageWrapper from "@components/PageWrapper";
|
2022-02-11 22:20:10 +00:00
|
|
|
import BookingPage from "@components/booking/pages/BookingPage";
|
|
|
|
|
|
|
|
import { ssrInit } from "@server/lib/ssr";
|
|
|
|
|
2021-09-22 18:36:13 +00:00
|
|
|
export type BookPageProps = inferSSRProps<typeof getServerSideProps>;
|
|
|
|
|
|
|
|
export default function Book(props: BookPageProps) {
|
2022-04-06 17:20:30 +00:00
|
|
|
const { t } = useLocale();
|
2022-04-22 15:03:01 +00:00
|
|
|
return props.away ? (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="dark:bg-inverted h-screen">
|
2022-04-22 15:03:01 +00:00
|
|
|
<main className="mx-auto max-w-3xl px-4 py-24">
|
|
|
|
<div className="space-y-6" data-testid="event-types">
|
|
|
|
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="text-muted dark:text-inverted p-8 text-center">
|
|
|
|
<h2 className="font-cal dark:text-inverted text-default mb-2 text-3xl">
|
2022-04-22 15:03:01 +00:00
|
|
|
😴{" " + t("user_away")}
|
|
|
|
</h2>
|
|
|
|
<p className="mx-auto max-w-md">{t("user_away_description")}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
) : props.isDynamicGroupBooking && !props.profile.allowDynamicBooking ? (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="dark:bg-inverted h-screen">
|
2022-04-06 17:20:30 +00:00
|
|
|
<main className="mx-auto max-w-3xl px-4 py-24">
|
|
|
|
<div className="space-y-6" data-testid="event-types">
|
|
|
|
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="text-muted dark:text-inverted p-8 text-center">
|
|
|
|
<h2 className="font-cal dark:text-inverted text-default mb-2 text-3xl">
|
2022-04-06 17:20:30 +00:00
|
|
|
{" " + t("unavailable")}
|
|
|
|
</h2>
|
|
|
|
<p className="mx-auto max-w-md">{t("user_dynamic_booking_disabled")}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
) : (
|
2022-08-26 00:48:50 +00:00
|
|
|
<BookingPage {...props} />
|
2022-04-06 17:20:30 +00:00
|
|
|
);
|
2021-03-22 13:48:48 +00:00
|
|
|
}
|
|
|
|
|
2023-04-17 12:16:54 +00:00
|
|
|
Book.isBookingPage = true;
|
2023-04-18 18:45:32 +00:00
|
|
|
Book.PageWrapper = PageWrapper;
|
2023-04-17 12:16:54 +00:00
|
|
|
|
2023-03-14 04:19:05 +00:00
|
|
|
const querySchema = z.object({
|
|
|
|
bookingUid: z.string().optional(),
|
|
|
|
count: z.coerce.number().optional(),
|
|
|
|
embed: z.string().optional(),
|
|
|
|
rescheduleUid: z.string().optional(),
|
|
|
|
slug: z.string().optional(),
|
|
|
|
/** This is the event "type" ID */
|
|
|
|
type: z.coerce.number().optional(),
|
|
|
|
user: z.string(),
|
|
|
|
seatReferenceUid: z.string().optional(),
|
|
|
|
date: z.string().optional(),
|
|
|
|
duration: z.coerce.number().optional(),
|
|
|
|
});
|
|
|
|
|
2021-09-22 18:36:13 +00:00
|
|
|
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
2021-10-20 16:00:11 +00:00
|
|
|
const ssr = await ssrInit(context);
|
2023-03-14 04:19:05 +00:00
|
|
|
const query = querySchema.parse(context.query);
|
|
|
|
const usernameList = getUsernameList(query.user);
|
|
|
|
const eventTypeSlug = query.slug;
|
|
|
|
const recurringEventCountQuery = query.count;
|
2022-04-06 17:20:30 +00:00
|
|
|
const users = await prisma.user.findMany({
|
2021-09-14 08:45:28 +00:00
|
|
|
where: {
|
2022-04-06 17:20:30 +00:00
|
|
|
username: {
|
|
|
|
in: usernameList,
|
|
|
|
},
|
2021-07-11 19:35:56 +00:00
|
|
|
},
|
2021-09-14 08:45:28 +00:00
|
|
|
select: {
|
2022-02-01 21:48:40 +00:00
|
|
|
id: true,
|
2021-09-14 08:45:28 +00:00
|
|
|
username: true,
|
|
|
|
name: true,
|
|
|
|
email: true,
|
|
|
|
bio: true,
|
|
|
|
avatar: true,
|
|
|
|
theme: true,
|
2021-11-16 08:51:46 +00:00
|
|
|
brandColor: true,
|
2022-03-05 15:37:46 +00:00
|
|
|
darkBrandColor: true,
|
2022-04-06 17:20:30 +00:00
|
|
|
allowDynamicBooking: true,
|
2022-04-22 15:03:01 +00:00
|
|
|
away: true,
|
2023-02-15 15:42:49 +00:00
|
|
|
metadata: true,
|
2021-09-14 08:45:28 +00:00
|
|
|
},
|
|
|
|
});
|
2021-03-22 13:48:48 +00:00
|
|
|
|
2022-04-06 17:20:30 +00:00
|
|
|
if (!users.length) return { notFound: true };
|
|
|
|
const [user] = users;
|
2023-03-14 04:19:05 +00:00
|
|
|
const isDynamicGroupBooking = users.length > 1 && !!eventTypeSlug;
|
2022-05-11 05:41:09 +00:00
|
|
|
|
|
|
|
// Dynamic Group link doesn't need a type but it must have a slug
|
2023-03-14 04:19:05 +00:00
|
|
|
if ((!isDynamicGroupBooking && !query.type) || (users.length > 1 && !eventTypeSlug)) {
|
2022-05-11 05:41:09 +00:00
|
|
|
return { notFound: true };
|
|
|
|
}
|
|
|
|
|
2023-03-14 04:19:05 +00:00
|
|
|
const eventTypeRaw = isDynamicGroupBooking
|
|
|
|
? getDefaultEvent(eventTypeSlug)
|
|
|
|
: await prisma.eventType.findUnique({
|
|
|
|
where: {
|
|
|
|
id: query.type,
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
...bookEventTypeSelect,
|
|
|
|
},
|
|
|
|
});
|
2021-06-09 18:28:39 +00:00
|
|
|
|
2022-02-01 21:48:40 +00:00
|
|
|
if (!eventTypeRaw) return { notFound: true };
|
|
|
|
const eventType = {
|
|
|
|
...eventTypeRaw,
|
2022-11-28 18:14:01 +00:00
|
|
|
metadata: EventTypeMetaDataSchema.parse(eventTypeRaw.metadata || {}),
|
2023-03-02 18:15:28 +00:00
|
|
|
bookingFields: getBookingFieldsWithSystemFields(eventTypeRaw),
|
2022-06-10 00:32:34 +00:00
|
|
|
recurringEvent: parseRecurringEvent(eventTypeRaw.recurringEvent),
|
2022-02-01 21:48:40 +00:00
|
|
|
};
|
2021-09-22 18:36:13 +00:00
|
|
|
|
2023-02-15 15:42:49 +00:00
|
|
|
const getLocations = () => {
|
2022-08-26 00:48:50 +00:00
|
|
|
let locations = eventTypeRaw.locations || [];
|
2023-02-15 15:42:49 +00:00
|
|
|
if (!isDynamicGroupBooking) return locations;
|
|
|
|
|
|
|
|
let sortedUsers: typeof users = [];
|
|
|
|
// sort and be in the same order as usernameList so first user is the first user in the list
|
|
|
|
if (users.length > 1) {
|
|
|
|
sortedUsers = users.sort((a, b) => {
|
|
|
|
const aIndex = (a.username && usernameList.indexOf(a.username)) || 0;
|
|
|
|
const bIndex = (b.username && usernameList.indexOf(b.username)) || 0;
|
|
|
|
return aIndex - bIndex;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the prefered location type from the first user
|
|
|
|
const firstUsersMetadata = userMetadataSchema.parse(sortedUsers[0].metadata || {});
|
|
|
|
const preferedLocationType = firstUsersMetadata?.defaultConferencingApp;
|
|
|
|
|
|
|
|
if (preferedLocationType?.appSlug) {
|
|
|
|
const foundApp = getAppFromSlug(preferedLocationType.appSlug);
|
|
|
|
const appType = foundApp?.appData?.location?.type;
|
|
|
|
if (appType) {
|
|
|
|
// Replace the location with the prefered location type
|
|
|
|
// This will still be default to daily if the app is not found
|
|
|
|
locations = [{ type: appType, link: preferedLocationType.appLink }] as LocationObject[];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return locations;
|
|
|
|
};
|
|
|
|
|
|
|
|
const eventTypeObject = [eventType].map((e) => {
|
|
|
|
let locations = getLocations();
|
2022-08-26 00:48:50 +00:00
|
|
|
locations = privacyFilteredLocations(locations as LocationObject[]);
|
2021-08-08 16:17:17 +00:00
|
|
|
return {
|
|
|
|
...e,
|
2022-08-26 00:48:50 +00:00
|
|
|
locations: locations,
|
2021-08-08 16:17:17 +00:00
|
|
|
periodStartDate: e.periodStartDate?.toString() ?? null,
|
|
|
|
periodEndDate: e.periodEndDate?.toString() ?? null,
|
2022-08-15 19:52:01 +00:00
|
|
|
schedulingType: null,
|
2022-12-01 21:53:52 +00:00
|
|
|
customInputs: customInputSchema.array().parse(e.customInputs || []),
|
2022-08-12 19:29:29 +00:00
|
|
|
users: users.map((u) => ({
|
|
|
|
id: u.id,
|
|
|
|
name: u.name,
|
|
|
|
username: u.username,
|
|
|
|
avatar: u.avatar,
|
|
|
|
image: u.avatar,
|
|
|
|
slug: u.username,
|
|
|
|
theme: u.theme,
|
|
|
|
})),
|
2023-03-28 09:40:13 +00:00
|
|
|
descriptionAsSafeHTML: markdownToSafeHTML(eventType.description),
|
2021-08-08 16:17:17 +00:00
|
|
|
};
|
2021-08-04 10:39:43 +00:00
|
|
|
})[0];
|
2021-07-15 14:10:26 +00:00
|
|
|
|
2023-03-14 04:19:05 +00:00
|
|
|
// If rescheduleUid and event has seats lets convert Uid to bookingUid
|
|
|
|
let rescheduleUid = query.rescheduleUid;
|
|
|
|
const rescheduleEventTypeHasSeats = query.rescheduleUid && eventTypeRaw.seatsPerTimeSlot;
|
|
|
|
let attendeeEmail: string;
|
|
|
|
let bookingUidWithSeats: string | null = null;
|
|
|
|
|
|
|
|
if (rescheduleEventTypeHasSeats) {
|
|
|
|
const bookingSeat = await prisma.bookingSeat.findFirst({
|
|
|
|
where: {
|
|
|
|
referenceUid: query.rescheduleUid,
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
attendee: true,
|
|
|
|
booking: {
|
|
|
|
select: {
|
|
|
|
uid: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (bookingSeat) {
|
|
|
|
rescheduleUid = bookingSeat.booking.uid;
|
|
|
|
attendeeEmail = bookingSeat.attendee.email;
|
|
|
|
}
|
2023-03-27 09:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (query.duration) {
|
2023-03-14 04:19:05 +00:00
|
|
|
// If it's not reschedule but event Type has seats we should obtain
|
|
|
|
// the bookingUid regardless and use it to get the booking
|
|
|
|
const currentSeats = await prisma.booking.findFirst({
|
|
|
|
where: {
|
|
|
|
eventTypeId: eventTypeRaw.id,
|
|
|
|
startTime: dayjs(query.date).toISOString(),
|
|
|
|
endTime: dayjs(query.date).add(query.duration, "minutes").toISOString(),
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
uid: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (currentSeats && currentSeats) {
|
|
|
|
bookingUidWithSeats = currentSeats.uid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-14 21:25:24 +00:00
|
|
|
let booking: GetBookingType | null = null;
|
2023-03-14 04:19:05 +00:00
|
|
|
if (rescheduleUid || query.bookingUid || bookingUidWithSeats) {
|
2023-03-27 08:27:10 +00:00
|
|
|
booking = await getBooking(prisma, rescheduleUid || query.bookingUid || bookingUidWithSeats || "");
|
2022-02-10 17:42:06 +00:00
|
|
|
}
|
|
|
|
|
2023-03-14 04:19:05 +00:00
|
|
|
if (rescheduleEventTypeHasSeats && booking?.attendees && booking?.attendees.length > 0) {
|
|
|
|
const currentAttendee = booking?.attendees.find((attendee) => {
|
|
|
|
return attendee.email === attendeeEmail;
|
|
|
|
});
|
|
|
|
if (currentAttendee) {
|
|
|
|
booking.attendees = [currentAttendee] || [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const dynamicNames = isDynamicGroupBooking ? users.map((user) => user.name || "") : [];
|
2022-04-07 13:41:26 +00:00
|
|
|
|
2022-04-06 17:20:30 +00:00
|
|
|
const profile = isDynamicGroupBooking
|
|
|
|
? {
|
2022-04-07 13:41:26 +00:00
|
|
|
name: getGroupName(dynamicNames),
|
2022-04-06 17:20:30 +00:00
|
|
|
image: null,
|
|
|
|
slug: eventTypeSlug,
|
|
|
|
theme: null,
|
|
|
|
brandColor: "",
|
|
|
|
darkBrandColor: "",
|
2023-03-14 04:19:05 +00:00
|
|
|
allowDynamicBooking: !users.some((user) => !user.allowDynamicBooking),
|
2022-04-08 16:50:10 +00:00
|
|
|
eventName: getDynamicEventName(dynamicNames, eventTypeSlug),
|
2022-04-06 17:20:30 +00:00
|
|
|
}
|
|
|
|
: {
|
|
|
|
name: user.name || user.username,
|
|
|
|
image: user.avatar,
|
|
|
|
slug: user.username,
|
|
|
|
theme: user.theme,
|
|
|
|
brandColor: user.brandColor,
|
|
|
|
darkBrandColor: user.darkBrandColor,
|
2022-04-08 16:50:10 +00:00
|
|
|
eventName: null,
|
2022-04-06 17:20:30 +00:00
|
|
|
};
|
|
|
|
|
2022-05-05 21:16:25 +00:00
|
|
|
// Checking if number of recurring event ocurrances is valid against event type configuration
|
|
|
|
const recurringEventCount =
|
|
|
|
(eventType.recurringEvent?.count &&
|
|
|
|
recurringEventCountQuery &&
|
2023-03-14 04:19:05 +00:00
|
|
|
(recurringEventCountQuery <= eventType.recurringEvent.count
|
|
|
|
? recurringEventCountQuery
|
2022-05-05 21:16:25 +00:00
|
|
|
: eventType.recurringEvent.count)) ||
|
|
|
|
null;
|
|
|
|
|
2023-03-27 11:32:35 +00:00
|
|
|
const currentSlotBooking = await getBooking(prisma, bookingUidWithSeats || "");
|
2023-03-27 09:34:41 +00:00
|
|
|
|
2021-06-24 22:26:55 +00:00
|
|
|
return {
|
|
|
|
props: {
|
2022-04-22 15:03:01 +00:00
|
|
|
away: user.away,
|
2022-04-06 17:20:30 +00:00
|
|
|
profile,
|
2021-07-15 14:10:26 +00:00
|
|
|
eventType: eventTypeObject,
|
2021-06-24 22:26:55 +00:00
|
|
|
booking,
|
2023-03-27 09:34:41 +00:00
|
|
|
currentSlotBooking: currentSlotBooking,
|
2022-05-05 21:16:25 +00:00
|
|
|
recurringEventCount,
|
2021-10-20 16:00:11 +00:00
|
|
|
trpcState: ssr.dehydrate(),
|
2022-04-06 17:20:30 +00:00
|
|
|
isDynamicGroupBooking,
|
2022-04-28 15:44:26 +00:00
|
|
|
hasHashedBookingLink: false,
|
|
|
|
hashedLink: null,
|
2023-03-14 04:19:05 +00:00
|
|
|
isEmbed: !!query.embed,
|
2021-06-24 22:26:55 +00:00
|
|
|
},
|
|
|
|
};
|
2021-06-15 15:26:16 +00:00
|
|
|
}
|