2022-04-06 17:20:30 +00:00
|
|
|
import { UserPlan } from "@prisma/client";
|
2022-04-25 04:33:00 +00:00
|
|
|
import classNames from "classnames";
|
2021-10-08 11:43:48 +00:00
|
|
|
import { GetServerSidePropsContext } from "next";
|
2022-02-11 14:34:12 +00:00
|
|
|
import dynamic from "next/dynamic";
|
2021-09-06 13:51:15 +00:00
|
|
|
import Link from "next/link";
|
2021-12-03 10:15:20 +00:00
|
|
|
import { useRouter } from "next/router";
|
2022-05-17 20:43:27 +00:00
|
|
|
import { useEffect, useState } from "react";
|
2022-02-01 21:48:40 +00:00
|
|
|
import { Toaster } from "react-hot-toast";
|
|
|
|
import { JSONObject } from "superjson/dist/types";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-05-27 15:37:02 +00:00
|
|
|
import {
|
|
|
|
sdkActionManager,
|
|
|
|
useEmbedNonStylesConfig,
|
|
|
|
useEmbedStyles,
|
|
|
|
useIsEmbed,
|
|
|
|
} from "@calcom/embed-core/embed-iframe";
|
2022-07-28 19:58:26 +00:00
|
|
|
import type { CryptoSectionProps } from "@calcom/features/ee/web3/components/CryptoSection";
|
2022-07-23 00:39:50 +00:00
|
|
|
import CustomBranding from "@calcom/lib/CustomBranding";
|
2022-04-06 17:20:30 +00:00
|
|
|
import defaultEvents, {
|
|
|
|
getDynamicEventDescription,
|
2022-04-25 04:33:00 +00:00
|
|
|
getGroupName,
|
2022-04-06 17:20:30 +00:00
|
|
|
getUsernameList,
|
|
|
|
getUsernameSlugLink,
|
|
|
|
} from "@calcom/lib/defaultEvents";
|
2022-03-31 08:45:47 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-07-28 19:58:26 +00:00
|
|
|
import useTheme from "@calcom/lib/hooks/useTheme";
|
|
|
|
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
|
|
|
|
import prisma from "@calcom/prisma";
|
|
|
|
import { baseEventTypeSelect } from "@calcom/prisma/selects";
|
2022-07-27 02:24:00 +00:00
|
|
|
import { BadgeCheckIcon, Icon } from "@calcom/ui/Icon";
|
2022-03-31 08:45:47 +00:00
|
|
|
|
2022-04-04 15:44:04 +00:00
|
|
|
import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
|
|
|
2022-04-06 17:20:30 +00:00
|
|
|
import AvatarGroup from "@components/ui/AvatarGroup";
|
2022-02-11 14:34:12 +00:00
|
|
|
import { AvatarSSR } from "@components/ui/AvatarSSR";
|
2021-03-22 13:48:48 +00:00
|
|
|
|
2021-10-20 16:00:11 +00:00
|
|
|
import { ssrInit } from "@server/lib/ssr";
|
|
|
|
|
2022-08-24 20:18:42 +00:00
|
|
|
const EventTypeDescription = dynamic(() => import("@calcom/ui/v2/modules/event-types/EventTypeDescription"));
|
2022-04-04 20:26:14 +00:00
|
|
|
const HeadSeo = dynamic(() => import("@components/seo/head-seo"));
|
2022-07-28 19:58:26 +00:00
|
|
|
const CryptoSection = dynamic<CryptoSectionProps>(
|
|
|
|
() => import("@calcom/features/ee/web3/components/CryptoSection")
|
|
|
|
);
|
2022-02-01 21:48:40 +00:00
|
|
|
|
|
|
|
interface EvtsToVerify {
|
|
|
|
[evtId: string]: boolean;
|
|
|
|
}
|
|
|
|
|
2021-10-08 11:43:48 +00:00
|
|
|
export default function User(props: inferSSRProps<typeof getServerSideProps>) {
|
2022-06-15 20:54:31 +00:00
|
|
|
const { users, profile, eventTypes, isDynamicGroup, dynamicNames, dynamicUsernames, isSingleUser } = props;
|
2022-04-06 17:20:30 +00:00
|
|
|
const [user] = users; //To be used when we only have a single user, not dynamic group
|
2022-07-26 08:27:57 +00:00
|
|
|
useTheme(user.theme);
|
2021-10-12 13:11:33 +00:00
|
|
|
const { t } = useLocale();
|
2021-12-03 10:15:20 +00:00
|
|
|
const router = useRouter();
|
2022-06-15 20:54:31 +00:00
|
|
|
|
2022-08-12 19:29:29 +00:00
|
|
|
const groupEventTypes = props.users.some((user) => !user.allowDynamicBooking) ? (
|
|
|
|
<div className="space-y-6" data-testid="event-types">
|
|
|
|
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
|
|
|
<div className="p-8 text-center text-gray-400 dark:text-white">
|
|
|
|
<h2 className="font-cal mb-2 text-3xl text-gray-600 dark:text-white">{" " + t("unavailable")}</h2>
|
|
|
|
<p className="mx-auto max-w-md">{t("user_dynamic_booking_disabled") as string}</p>
|
2022-04-06 17:20:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-12 19:29:29 +00:00
|
|
|
</div>
|
|
|
|
) : (
|
2022-08-24 20:18:42 +00:00
|
|
|
<ul>
|
2022-08-12 19:29:29 +00:00
|
|
|
{eventTypes.map((type, index) => (
|
|
|
|
<li
|
|
|
|
key={index}
|
2022-08-24 20:18:42 +00:00
|
|
|
className="hover:border-brand dark:bg-darkgray-100 group relative rounded-sm border border-neutral-200 bg-white dark:border-neutral-700 dark:hover:border-neutral-600">
|
2022-08-12 19:29:29 +00:00
|
|
|
<Icon.FiArrowRight className="absolute right-3 top-3 h-4 w-4 text-black opacity-0 transition-opacity group-hover:opacity-100 dark:text-white" />
|
|
|
|
<Link href={getUsernameSlugLink({ users: props.users, slug: type.slug })}>
|
|
|
|
<a className="flex justify-between px-6 py-4" data-testid="event-type-link">
|
|
|
|
<div className="flex-shrink">
|
2022-08-24 20:18:42 +00:00
|
|
|
<p className="dark:text-darkgray-700 text-sm font-semibold text-neutral-900">{type.title}</p>
|
2022-08-12 19:29:29 +00:00
|
|
|
<EventTypeDescription className="text-sm" eventType={type} />
|
|
|
|
</div>
|
|
|
|
<div className="mt-1 self-center">
|
|
|
|
<AvatarGroup
|
|
|
|
border="border-2 border-white"
|
|
|
|
truncateAfter={4}
|
|
|
|
className="flex flex-shrink-0"
|
|
|
|
size={10}
|
|
|
|
items={props.users.map((user) => ({
|
|
|
|
alt: user.name || "",
|
|
|
|
image: user.avatar || "",
|
|
|
|
}))}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
|
2022-04-25 04:33:00 +00:00
|
|
|
const isEmbed = useIsEmbed();
|
2022-03-31 08:45:47 +00:00
|
|
|
const eventTypeListItemEmbedStyles = useEmbedStyles("eventTypeListItem");
|
2022-04-25 04:33:00 +00:00
|
|
|
const shouldAlignCentrallyInEmbed = useEmbedNonStylesConfig("align") !== "left";
|
|
|
|
const shouldAlignCentrally = !isEmbed || shouldAlignCentrallyInEmbed;
|
2021-12-09 15:51:37 +00:00
|
|
|
const query = { ...router.query };
|
|
|
|
delete query.user; // So it doesn't display in the Link (and make tests fail)
|
2022-04-04 15:44:04 +00:00
|
|
|
useExposePlanGlobally("PRO");
|
2021-10-20 16:00:11 +00:00
|
|
|
const nameOrUsername = user.name || user.username || "";
|
2022-02-01 21:48:40 +00:00
|
|
|
const [evtsToVerify, setEvtsToVerify] = useState<EvtsToVerify>({});
|
2022-04-14 02:47:34 +00:00
|
|
|
const telemetry = useTelemetry();
|
|
|
|
|
|
|
|
useEffect(() => {
|
2022-06-02 16:19:01 +00:00
|
|
|
if (top !== window) {
|
|
|
|
//page_view will be collected automatically by _middleware.ts
|
|
|
|
telemetry.event(telemetryEventTypes.embedView, collectPageParameters("/[user]"));
|
|
|
|
}
|
|
|
|
}, [telemetry, router.asPath]);
|
|
|
|
|
2021-07-11 19:35:56 +00:00
|
|
|
return (
|
2021-08-12 17:05:46 +00:00
|
|
|
<>
|
2021-08-27 12:35:20 +00:00
|
|
|
<HeadSeo
|
2022-04-07 10:28:52 +00:00
|
|
|
title={isDynamicGroup ? dynamicNames.join(", ") : nameOrUsername}
|
|
|
|
description={
|
|
|
|
isDynamicGroup ? `Book events with ${dynamicUsernames.join(", ")}` : (user.bio as string) || ""
|
|
|
|
}
|
|
|
|
name={isDynamicGroup ? dynamicNames.join(", ") : nameOrUsername}
|
|
|
|
username={isDynamicGroup ? dynamicUsernames.join(", ") : (user.username as string) || ""}
|
2022-01-11 08:54:02 +00:00
|
|
|
// avatar={user.avatar || undefined}
|
2021-08-27 12:35:20 +00:00
|
|
|
/>
|
2022-04-25 04:33:00 +00:00
|
|
|
<CustomBranding lightVal={profile.brandColor} darkVal={profile.darkBrandColor} />
|
|
|
|
|
2022-08-24 20:18:42 +00:00
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
shouldAlignCentrally ? "mx-auto" : "",
|
|
|
|
isEmbed ? "max-w-3xl" : "",
|
|
|
|
"dark:bg-darkgray-50"
|
|
|
|
)}>
|
2022-04-25 04:33:00 +00:00
|
|
|
<main
|
|
|
|
className={classNames(
|
|
|
|
shouldAlignCentrally ? "mx-auto" : "",
|
|
|
|
isEmbed
|
2022-08-24 20:18:42 +00:00
|
|
|
? " border-bookinglightest dark:bg-darkgray-50 rounded-md border bg-white sm:dark:border-gray-600"
|
2022-04-25 04:33:00 +00:00
|
|
|
: "",
|
|
|
|
"max-w-3xl py-24 px-4"
|
|
|
|
)}>
|
2022-04-06 17:20:30 +00:00
|
|
|
{isSingleUser && ( // When we deal with a single user, not dynamic group
|
|
|
|
<div className="mb-8 text-center">
|
2022-07-13 21:14:16 +00:00
|
|
|
<AvatarSSR user={user} className="mx-auto mb-4 h-24 w-24" alt={nameOrUsername} />
|
2022-04-06 17:20:30 +00:00
|
|
|
<h1 className="font-cal mb-1 text-3xl text-neutral-900 dark:text-white">
|
|
|
|
{nameOrUsername}
|
|
|
|
{user.verified && (
|
|
|
|
<BadgeCheckIcon className="mx-1 -mt-1 inline h-6 w-6 text-blue-500 dark:text-white" />
|
|
|
|
)}
|
|
|
|
</h1>
|
2022-08-24 20:18:42 +00:00
|
|
|
<p className="dark:text-darkgray-600 text-s text-neutral-500">{user.bio}</p>
|
2022-04-06 17:20:30 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2022-08-24 20:18:42 +00:00
|
|
|
<div
|
|
|
|
className="rounded-md border border-neutral-200 dark:border-neutral-700 dark:hover:border-neutral-600"
|
|
|
|
data-testid="event-types">
|
2022-03-10 19:21:27 +00:00
|
|
|
{user.away ? (
|
|
|
|
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
|
|
|
<div className="p-8 text-center text-gray-400 dark:text-white">
|
2022-03-15 16:59:04 +00:00
|
|
|
<h2 className="font-cal mb-2 text-3xl text-gray-600 dark:text-white">
|
2022-03-10 19:21:27 +00:00
|
|
|
😴{" " + t("user_away")}
|
|
|
|
</h2>
|
2022-05-20 07:06:21 +00:00
|
|
|
<p className="mx-auto max-w-md">{t("user_away_description") as string}</p>
|
2022-03-10 19:21:27 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-04-06 17:20:30 +00:00
|
|
|
) : isDynamicGroup ? ( //When we deal with dynamic group (users > 1)
|
|
|
|
groupEventTypes
|
2022-03-10 19:21:27 +00:00
|
|
|
) : (
|
2022-02-11 14:34:12 +00:00
|
|
|
eventTypes.map((type) => (
|
|
|
|
<div
|
|
|
|
key={type.id}
|
2022-03-31 08:45:47 +00:00
|
|
|
style={{ display: "flex", ...eventTypeListItemEmbedStyles }}
|
2022-08-24 20:18:42 +00:00
|
|
|
className="hover:border-brand dark:bg-darkgray-100 group relative border-b border-neutral-200 bg-white first:rounded-t-md last:rounded-b-md last:border-b-0 hover:bg-white dark:border-neutral-700 dark:hover:border-neutral-600">
|
2022-08-05 08:46:44 +00:00
|
|
|
<Icon.FiArrowRight className="absolute right-4 top-4 h-4 w-4 text-black opacity-0 transition-opacity group-hover:opacity-100 dark:text-white" />
|
2022-03-05 15:28:24 +00:00
|
|
|
{/* Don't prefetch till the time we drop the amount of javascript in [user][type] page which is impacting score for [user] page */}
|
2022-02-11 14:34:12 +00:00
|
|
|
<Link
|
2022-03-05 15:28:24 +00:00
|
|
|
prefetch={false}
|
2022-02-11 14:34:12 +00:00
|
|
|
href={{
|
|
|
|
pathname: `/${user.username}/${type.slug}`,
|
|
|
|
query,
|
|
|
|
}}>
|
|
|
|
<a
|
|
|
|
onClick={async (e) => {
|
|
|
|
// If a token is required for this event type, add a click listener that checks whether the user verified their wallet or not
|
|
|
|
if (type.metadata.smartContractAddress && !evtsToVerify[type.id]) {
|
2022-03-16 23:36:43 +00:00
|
|
|
const showToast = (await import("@calcom/lib/notification")).default;
|
2022-02-11 14:34:12 +00:00
|
|
|
e.preventDefault();
|
|
|
|
showToast(
|
|
|
|
"You must verify a wallet with a token belonging to the specified smart contract first",
|
|
|
|
"error"
|
|
|
|
);
|
2022-03-31 08:45:47 +00:00
|
|
|
} else {
|
|
|
|
sdkActionManager?.fire("eventTypeSelected", {
|
|
|
|
eventType: type,
|
|
|
|
});
|
2022-02-11 14:34:12 +00:00
|
|
|
}
|
|
|
|
}}
|
2022-08-05 08:46:44 +00:00
|
|
|
className="block w-full p-5"
|
2022-02-11 14:34:12 +00:00
|
|
|
data-testid="event-type-link">
|
|
|
|
<h2 className="grow font-semibold text-neutral-900 dark:text-white">{type.title}</h2>
|
|
|
|
<EventTypeDescription eventType={type} />
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
{type.isWeb3Active && type.metadata.smartContractAddress && (
|
|
|
|
<CryptoSection
|
|
|
|
id={type.id}
|
|
|
|
pathname={`/${user.username}/${type.slug}`}
|
|
|
|
smartContractAddress={type.metadata.smartContractAddress as string}
|
|
|
|
verified={evtsToVerify[type.id]}
|
|
|
|
setEvtsToVerify={setEvtsToVerify}
|
|
|
|
oneStep
|
|
|
|
/>
|
|
|
|
)}
|
2021-08-12 17:05:46 +00:00
|
|
|
</div>
|
2022-03-10 19:21:27 +00:00
|
|
|
))
|
|
|
|
)}
|
2022-02-11 14:34:12 +00:00
|
|
|
</div>
|
|
|
|
{eventTypes.length === 0 && (
|
2022-03-10 19:21:27 +00:00
|
|
|
<div className="overflow-hidden rounded-sm border dark:border-gray-900">
|
2022-02-11 14:34:12 +00:00
|
|
|
<div className="p-8 text-center text-gray-400 dark:text-white">
|
2022-05-20 07:06:21 +00:00
|
|
|
<h2 className="font-cal mb-2 text-3xl text-gray-600 dark:text-white">
|
|
|
|
{t("uh_oh") as string}
|
|
|
|
</h2>
|
|
|
|
<p className="mx-auto max-w-md">{t("no_event_types_have_been_setup") as string}</p>
|
2021-08-12 17:05:46 +00:00
|
|
|
</div>
|
2022-02-11 14:34:12 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</main>
|
|
|
|
<Toaster position="bottom-right" />
|
|
|
|
</div>
|
2021-08-12 17:05:46 +00:00
|
|
|
</>
|
2021-06-22 17:42:32 +00:00
|
|
|
);
|
2021-03-22 13:48:48 +00:00
|
|
|
}
|
2022-07-26 08:27:57 +00:00
|
|
|
User.isThemeSupported = true;
|
2021-03-22 13:48:48 +00:00
|
|
|
|
2022-04-06 17:20:30 +00:00
|
|
|
const getEventTypesWithHiddenFromDB = async (userId: number, plan: UserPlan) => {
|
|
|
|
return await prisma.eventType.findMany({
|
2021-10-08 11:43:48 +00:00
|
|
|
where: {
|
|
|
|
AND: [
|
|
|
|
{
|
|
|
|
teamId: null,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
OR: [
|
|
|
|
{
|
2022-04-06 17:20:30 +00:00
|
|
|
userId,
|
2021-10-08 11:43:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
users: {
|
|
|
|
some: {
|
2022-04-06 17:20:30 +00:00
|
|
|
id: userId,
|
2021-10-08 11:43:48 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-11-15 12:25:49 +00:00
|
|
|
orderBy: [
|
|
|
|
{
|
|
|
|
position: "desc",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "asc",
|
|
|
|
},
|
|
|
|
],
|
2021-10-08 11:43:48 +00:00
|
|
|
select: {
|
2022-02-01 21:48:40 +00:00
|
|
|
metadata: true,
|
2022-06-06 16:54:47 +00:00
|
|
|
...baseEventTypeSelect,
|
2021-10-08 11:43:48 +00:00
|
|
|
},
|
2022-04-06 17:20:30 +00:00
|
|
|
take: plan === UserPlan.FREE ? 1 : undefined,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
|
|
const ssr = await ssrInit(context);
|
2022-05-17 20:43:27 +00:00
|
|
|
const crypto = await import("crypto");
|
2022-04-06 17:20:30 +00:00
|
|
|
|
|
|
|
const usernameList = getUsernameList(context.query.user as string);
|
|
|
|
const dataFetchStart = Date.now();
|
|
|
|
const users = await prisma.user.findMany({
|
|
|
|
where: {
|
|
|
|
username: {
|
|
|
|
in: usernameList,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
username: true,
|
|
|
|
email: true,
|
|
|
|
name: true,
|
|
|
|
bio: true,
|
2022-04-25 04:33:00 +00:00
|
|
|
brandColor: true,
|
|
|
|
darkBrandColor: true,
|
2022-04-06 17:20:30 +00:00
|
|
|
avatar: true,
|
|
|
|
theme: true,
|
|
|
|
plan: true,
|
|
|
|
away: true,
|
|
|
|
verified: true,
|
|
|
|
allowDynamicBooking: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!users.length) {
|
|
|
|
return {
|
|
|
|
notFound: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const isDynamicGroup = users.length > 1;
|
|
|
|
|
2022-04-25 04:33:00 +00:00
|
|
|
const dynamicNames = isDynamicGroup
|
|
|
|
? users.map((user) => {
|
|
|
|
return user.name || "";
|
|
|
|
})
|
|
|
|
: [];
|
2022-04-06 17:20:30 +00:00
|
|
|
const [user] = users; //to be used when dealing with single user, not dynamic group
|
2022-04-25 04:33:00 +00:00
|
|
|
|
|
|
|
const profile = isDynamicGroup
|
|
|
|
? {
|
|
|
|
name: getGroupName(dynamicNames),
|
|
|
|
image: null,
|
|
|
|
theme: null,
|
|
|
|
weekStart: "Sunday",
|
|
|
|
brandColor: "",
|
|
|
|
darkBrandColor: "",
|
2022-05-26 16:41:05 +00:00
|
|
|
allowDynamicBooking: !users.some((user) => {
|
2022-04-25 04:33:00 +00:00
|
|
|
return !user.allowDynamicBooking;
|
2022-05-26 16:41:05 +00:00
|
|
|
}),
|
2022-04-25 04:33:00 +00:00
|
|
|
}
|
|
|
|
: {
|
|
|
|
name: user.name || user.username,
|
|
|
|
image: user.avatar,
|
|
|
|
theme: user.theme,
|
|
|
|
brandColor: user.brandColor,
|
|
|
|
darkBrandColor: user.darkBrandColor,
|
|
|
|
};
|
2022-04-06 17:20:30 +00:00
|
|
|
const usersIds = users.map((user) => user.id);
|
|
|
|
const credentials = await prisma.credential.findMany({
|
|
|
|
where: {
|
|
|
|
userId: {
|
|
|
|
in: usersIds,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
type: true,
|
|
|
|
key: true,
|
|
|
|
},
|
2021-10-08 11:43:48 +00:00
|
|
|
});
|
2022-04-06 17:20:30 +00:00
|
|
|
|
|
|
|
const web3Credentials = credentials.find((credential) => credential.type.includes("_web3"));
|
|
|
|
|
|
|
|
const eventTypesWithHidden = isDynamicGroup ? [] : await getEventTypesWithHiddenFromDB(user.id, user.plan);
|
2022-03-04 10:03:10 +00:00
|
|
|
const dataFetchEnd = Date.now();
|
|
|
|
if (context.query.log === "1") {
|
|
|
|
context.res.setHeader("X-Data-Fetch-Time", `${dataFetchEnd - dataFetchStart}ms`);
|
|
|
|
}
|
2022-02-01 21:48:40 +00:00
|
|
|
const eventTypesRaw = eventTypesWithHidden.filter((evt) => !evt.hidden);
|
|
|
|
|
|
|
|
const eventTypes = eventTypesRaw.map((eventType) => ({
|
|
|
|
...eventType,
|
|
|
|
metadata: (eventType.metadata || {}) as JSONObject,
|
|
|
|
isWeb3Active:
|
|
|
|
web3Credentials && web3Credentials.key
|
|
|
|
? (((web3Credentials.key as JSONObject).isWeb3Active || false) as boolean)
|
|
|
|
: false,
|
|
|
|
}));
|
2021-10-08 11:43:48 +00:00
|
|
|
|
2022-06-15 20:54:31 +00:00
|
|
|
const isSingleUser = users.length === 1;
|
|
|
|
const dynamicUsernames = isDynamicGroup
|
|
|
|
? users.map((user) => {
|
|
|
|
return user.username || "";
|
|
|
|
})
|
|
|
|
: [];
|
|
|
|
|
2021-06-22 17:42:32 +00:00
|
|
|
return {
|
|
|
|
props: {
|
2022-04-06 17:20:30 +00:00
|
|
|
users,
|
2022-04-25 04:33:00 +00:00
|
|
|
profile,
|
2022-02-11 14:34:12 +00:00
|
|
|
user: {
|
|
|
|
emailMd5: crypto.createHash("md5").update(user.email).digest("hex"),
|
|
|
|
},
|
2022-06-15 20:54:31 +00:00
|
|
|
eventTypes: isDynamicGroup
|
|
|
|
? defaultEvents.map((event) => {
|
|
|
|
event.description = getDynamicEventDescription(dynamicUsernames, event.slug);
|
|
|
|
return event;
|
|
|
|
})
|
|
|
|
: eventTypes,
|
2021-10-20 16:00:11 +00:00
|
|
|
trpcState: ssr.dehydrate(),
|
2022-06-15 20:54:31 +00:00
|
|
|
isDynamicGroup,
|
|
|
|
dynamicNames,
|
|
|
|
dynamicUsernames,
|
|
|
|
isSingleUser,
|
2021-06-22 17:42:32 +00:00
|
|
|
},
|
|
|
|
};
|
2021-10-08 11:43:48 +00:00
|
|
|
};
|