import classNames from "classnames"; import type { GetServerSidePropsContext } from "next"; import Link from "next/link"; import { useRouter } from "next/router"; import { useEffect } from "react"; import { useIsEmbed } from "@calcom/embed-core/embed-iframe"; import EventTypeDescription from "@calcom/features/eventtypes/components/EventTypeDescription"; import { CAL_URL } from "@calcom/lib/constants"; import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import useTheme from "@calcom/lib/hooks/useTheme"; import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML"; import { getTeamWithMembers } from "@calcom/lib/server/queries/teams"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry"; import prisma from "@calcom/prisma"; import { Avatar, AvatarGroup, Button, EmptyScreen, HeadSeo } from "@calcom/ui"; import { FiArrowRight } from "@calcom/ui/components/icon"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; import type { inferSSRProps } from "@lib/types/inferSSRProps"; import Team from "@components/team/screens/Team"; import { ssrInit } from "@server/lib/ssr"; export type TeamPageProps = inferSSRProps; function TeamPage({ team, isUnpublished }: TeamPageProps) { useTheme(team.theme); const showMembers = useToggleQuery("members"); const { t } = useLocale(); const isEmbed = useIsEmbed(); const telemetry = useTelemetry(); const router = useRouter(); const teamName = team.name || "Nameless Team"; const isBioEmpty = !team.bio || !team.bio.replace("


", "").length; useEffect(() => { telemetry.event( telemetryEventTypes.pageView, collectPageParameters("/team/[slug]", { isTeamBooking: true }) ); }, [telemetry, router.asPath]); if (isUnpublished) { return (
} headline={t("team_is_unpublished", { team: teamName })} description={t("team_is_unpublished_description")} />
); } const EventTypes = () => ( ); return ( <>

{teamName}

{!isBioEmpty && ( <>
)}
{(showMembers.isOn || !team.eventTypes.length) && } {!showMembers.isOn && team.eventTypes.length > 0 && (
{!team.hideBookATeamMember && (
)}
)}
); } export const getServerSideProps = async (context: GetServerSidePropsContext) => { const ssr = await ssrInit(context); const slug = Array.isArray(context.query?.slug) ? context.query.slug.pop() : context.query.slug; const unpublishedTeam = await prisma.team.findFirst({ where: { metadata: { path: ["requestedSlug"], equals: slug, }, }, }); if (unpublishedTeam) { return { props: { isUnpublished: true, team: unpublishedTeam, trpcState: ssr.dehydrate(), }, } as const; } const team = await getTeamWithMembers(undefined, slug); if (!team) return { notFound: true } as { notFound: true }; team.eventTypes = team.eventTypes.map((type) => ({ ...type, users: type.users.map((user) => ({ ...user, avatar: CAL_URL + "/" + user.username + "/avatar.png", })), descriptionAsSafeHTML: markdownToSafeHTML(type.description), })); const safeBio = markdownToSafeHTML(team.bio) || ""; const members = team.members.map((member) => { return { ...member, safeBio: markdownToSafeHTML(member.bio || "") }; }); return { props: { team: { ...team, safeBio, members }, trpcState: ssr.dehydrate(), }, } as const; }; export default TeamPage;