2021-09-22 19:52:38 +00:00
|
|
|
import { ArrowRightIcon } from "@heroicons/react/solid";
|
2022-02-07 23:35:26 +00:00
|
|
|
import { UserPlan } from "@prisma/client";
|
2022-04-08 05:33:24 +00:00
|
|
|
import classNames from "classnames";
|
2021-09-29 21:33:18 +00:00
|
|
|
import { GetServerSidePropsContext } from "next";
|
2021-09-14 08:45:28 +00:00
|
|
|
import Link from "next/link";
|
2022-04-14 02:47:34 +00:00
|
|
|
import React, { useEffect } from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-05-27 15:37:02 +00:00
|
|
|
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
2022-05-09 18:25:12 +00:00
|
|
|
import { WEBSITE_URL } from "@calcom/lib/constants";
|
2022-03-16 23:36:43 +00:00
|
|
|
import Button from "@calcom/ui/Button";
|
|
|
|
|
2021-12-17 00:12:06 +00:00
|
|
|
import { getPlaceholderAvatar } from "@lib/getPlaceholderAvatar";
|
2022-04-04 15:44:04 +00:00
|
|
|
import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally";
|
2021-10-08 11:43:48 +00:00
|
|
|
import { useLocale } from "@lib/hooks/useLocale";
|
2021-09-14 08:45:28 +00:00
|
|
|
import useTheme from "@lib/hooks/useTheme";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { useToggleQuery } from "@lib/hooks/useToggleQuery";
|
2021-12-09 23:51:30 +00:00
|
|
|
import { getTeamWithMembers } from "@lib/queries/teams";
|
2022-04-14 02:47:34 +00:00
|
|
|
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
|
2021-09-29 21:33:18 +00:00
|
|
|
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-09-14 08:45:28 +00:00
|
|
|
import EventTypeDescription from "@components/eventtype/EventTypeDescription";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { HeadSeo } from "@components/seo/head-seo";
|
2021-09-14 08:45:28 +00:00
|
|
|
import Team from "@components/team/screens/Team";
|
2021-09-22 19:52:38 +00:00
|
|
|
import Avatar from "@components/ui/Avatar";
|
2021-09-14 08:45:28 +00:00
|
|
|
import AvatarGroup from "@components/ui/AvatarGroup";
|
2021-12-09 23:51:30 +00:00
|
|
|
import Text from "@components/ui/Text";
|
2021-09-14 08:45:28 +00:00
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
export type TeamPageProps = inferSSRProps<typeof getServerSideProps>;
|
|
|
|
function TeamPage({ team }: TeamPageProps) {
|
2022-02-10 11:07:14 +00:00
|
|
|
const { isReady, Theme } = useTheme();
|
2021-09-14 08:45:28 +00:00
|
|
|
const showMembers = useToggleQuery("members");
|
2021-10-12 13:11:33 +00:00
|
|
|
const { t } = useLocale();
|
2022-04-04 15:44:04 +00:00
|
|
|
useExposePlanGlobally("PRO");
|
2022-04-08 05:33:24 +00:00
|
|
|
const isEmbed = useIsEmbed();
|
2022-04-14 02:47:34 +00:00
|
|
|
const telemetry = useTelemetry();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
telemetry.withJitsu((jitsu) =>
|
|
|
|
jitsu.track(
|
|
|
|
telemetryEventTypes.pageView,
|
|
|
|
collectPageParameters("/team/[slug]", {
|
|
|
|
isTeamBooking: true,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}, [telemetry]);
|
2021-09-14 08:45:28 +00:00
|
|
|
const eventTypes = (
|
|
|
|
<ul className="space-y-3">
|
|
|
|
{team.eventTypes.map((type) => (
|
|
|
|
<li
|
|
|
|
key={type.id}
|
2022-04-08 05:33:24 +00:00
|
|
|
className={classNames(
|
|
|
|
"hover:border-brand group relative rounded-sm border border-neutral-200 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-neutral-600",
|
|
|
|
isEmbed ? "" : "bg-white hover:bg-gray-50"
|
|
|
|
)}>
|
2022-02-09 00:05:13 +00:00
|
|
|
<ArrowRightIcon className="absolute right-3 top-3 h-4 w-4 text-black opacity-0 transition-opacity group-hover:opacity-100 dark:text-white" />
|
2021-09-14 08:45:28 +00:00
|
|
|
<Link href={`${team.slug}/${type.slug}`}>
|
2021-12-09 23:51:30 +00:00
|
|
|
<a className="flex justify-between px-6 py-4">
|
2021-09-14 08:45:28 +00:00
|
|
|
<div className="flex-shrink">
|
2022-02-09 00:05:13 +00:00
|
|
|
<h2 className="font-cal font-semibold text-neutral-900 dark:text-white">{type.title}</h2>
|
2021-10-12 13:11:33 +00:00
|
|
|
<EventTypeDescription className="text-sm" eventType={type} />
|
2021-09-14 08:45:28 +00:00
|
|
|
</div>
|
2022-04-16 20:23:15 +00:00
|
|
|
<div className="mt-1 self-center">
|
2021-09-14 13:27:41 +00:00
|
|
|
<AvatarGroup
|
2022-03-24 13:15:24 +00:00
|
|
|
border="border-2 border-white dark:border-neutral-800"
|
2021-09-14 13:27:41 +00:00
|
|
|
truncateAfter={4}
|
2022-04-16 20:23:15 +00:00
|
|
|
className="flex flex-shrink-0"
|
2021-09-14 13:27:41 +00:00
|
|
|
size={10}
|
|
|
|
items={type.users.map((user) => ({
|
2021-09-29 21:33:18 +00:00
|
|
|
alt: user.name || "",
|
2022-05-09 18:25:12 +00:00
|
|
|
image: WEBSITE_URL + "/" + user.username + "/avatar.png" || "",
|
2021-09-14 13:27:41 +00:00
|
|
|
}))}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-09-14 08:45:28 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
|
2021-09-29 21:33:18 +00:00
|
|
|
const teamName = team.name || "Nameless Team";
|
|
|
|
|
2021-09-14 08:45:28 +00:00
|
|
|
return (
|
|
|
|
isReady && (
|
|
|
|
<div>
|
2022-02-10 11:07:14 +00:00
|
|
|
<Theme />
|
2021-09-29 21:33:18 +00:00
|
|
|
<HeadSeo title={teamName} description={teamName} />
|
2022-05-09 11:25:36 +00:00
|
|
|
<div className="rounded-md bg-white px-4 pt-24 pb-12 dark:bg-gray-900">
|
2022-02-09 22:32:31 +00:00
|
|
|
<div className="max-w-96 mx-auto mb-8 text-center">
|
2021-12-17 00:12:06 +00:00
|
|
|
<Avatar
|
|
|
|
alt={teamName}
|
|
|
|
imageSrc={getPlaceholderAvatar(team.logo, team.name)}
|
2022-02-09 00:05:13 +00:00
|
|
|
className="mx-auto mb-4 h-20 w-20 rounded-full"
|
2021-12-17 00:12:06 +00:00
|
|
|
/>
|
2022-03-21 23:14:00 +00:00
|
|
|
<Text variant="largetitle" className="text-gray-900 dark:text-white">
|
|
|
|
{teamName}
|
|
|
|
</Text>
|
2021-12-17 00:12:06 +00:00
|
|
|
<Text variant="subtitle" className="mt-2">
|
|
|
|
{team.bio}
|
|
|
|
</Text>
|
2021-12-09 23:51:30 +00:00
|
|
|
</div>
|
|
|
|
{(showMembers.isOn || !team.eventTypes.length) && <Team team={team} />}
|
|
|
|
{!showMembers.isOn && team.eventTypes.length > 0 && (
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mx-auto max-w-3xl">
|
2021-12-09 23:51:30 +00:00
|
|
|
{eventTypes}
|
|
|
|
<div className="relative mt-12">
|
|
|
|
<div className="absolute inset-0 flex items-center" aria-hidden="true">
|
2022-03-24 13:15:24 +00:00
|
|
|
<div className="w-full border-t border-gray-200 dark:border-gray-700" />
|
2021-12-09 23:51:30 +00:00
|
|
|
</div>
|
|
|
|
<div className="relative flex justify-center">
|
2022-02-09 22:32:31 +00:00
|
|
|
<span className="dark:bg-brand dark:text-brandcontrast bg-gray-100 px-2 text-sm text-gray-500">
|
2021-12-09 23:51:30 +00:00
|
|
|
{t("or")}
|
|
|
|
</span>
|
2021-09-14 13:27:41 +00:00
|
|
|
</div>
|
2021-12-07 16:11:43 +00:00
|
|
|
</div>
|
2021-12-09 23:51:30 +00:00
|
|
|
|
|
|
|
<aside className="mt-8 text-center dark:text-white">
|
|
|
|
<Button
|
|
|
|
color="secondary"
|
|
|
|
EndIcon={ArrowRightIcon}
|
|
|
|
href={`/team/${team.slug}?members=1`}
|
|
|
|
shallow={true}>
|
|
|
|
{t("book_a_team_member")}
|
|
|
|
</Button>
|
|
|
|
</aside>
|
|
|
|
</div>
|
|
|
|
)}
|
2021-09-14 08:45:28 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-29 21:33:18 +00:00
|
|
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
2021-09-14 08:45:28 +00:00
|
|
|
const slug = Array.isArray(context.query?.slug) ? context.query.slug.pop() : context.query.slug;
|
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
const team = await getTeamWithMembers(undefined, slug);
|
2021-09-14 08:45:28 +00:00
|
|
|
|
2021-09-29 21:33:18 +00:00
|
|
|
if (!team) return { notFound: true };
|
2021-09-14 08:45:28 +00:00
|
|
|
|
2022-02-07 23:35:26 +00:00
|
|
|
const members = team.members.filter((member) => member.plan !== UserPlan.FREE);
|
|
|
|
|
|
|
|
team.members = members ?? [];
|
|
|
|
|
2021-09-14 08:45:28 +00:00
|
|
|
team.eventTypes = team.eventTypes.map((type) => ({
|
|
|
|
...type,
|
|
|
|
users: type.users.map((user) => ({
|
|
|
|
...user,
|
2022-05-09 18:25:12 +00:00
|
|
|
avatar: WEBSITE_URL + "/" + user.username + "/avatar.png",
|
2021-09-14 08:45:28 +00:00
|
|
|
})),
|
|
|
|
}));
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
team,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TeamPage;
|