"use client"; // This route is reachable by // 1. /team/[slug] // 2. / (when on org domain e.g. http://calcom.cal.com/. This is through a rewrite from next.config.js) // Also the getServerSideProps and default export are reused by // 1. org/[orgSlug]/team/[slug] // 2. org/[orgSlug]/[user]/[type] import classNames from "classnames"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect } from "react"; import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe"; import EventTypeDescription from "@calcom/features/eventtypes/components/EventTypeDescription"; import { getOrgOrTeamAvatar } from "@calcom/lib/defaultAvatarImage"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery"; import { useTelemetry } from "@calcom/lib/hooks/useTelemetry"; import useTheme from "@calcom/lib/hooks/useTheme"; import { collectPageParameters, telemetryEventTypes } from "@calcom/lib/telemetry"; import { teamMetadataSchema } from "@calcom/prisma/zod-utils"; import { UserAvatarGroup } from "@calcom/ui/components/avatar"; import { Avatar } from "@calcom/ui/components/avatar"; import { Button } from "@calcom/ui/components/button"; import { UnpublishedEntity } from "@calcom/ui/components/unpublished-entity"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; import type { getServerSideProps } from "@lib/team/[slug]/getServerSideProps"; import type { inferSSRProps } from "@lib/types/inferSSRProps"; import Team from "@components/team/screens/Team"; export type PageProps = inferSSRProps; function TeamPage({ team, considerUnpublished, isValidOrgDomain }: PageProps) { useTheme(team.theme); const routerQuery = useRouterQuery(); const pathname = usePathname(); const showMembers = useToggleQuery("members"); const { t } = useLocale(); const isEmbed = useIsEmbed(); const telemetry = useTelemetry(); const teamName = team.name || t("nameless_team"); const isBioEmpty = !team.bio || !team.bio.replace("


", "").length; const metadata = teamMetadataSchema.parse(team.metadata); const teamOrOrgIsPrivate = team.isPrivate || (team?.parent?.isOrganization && team.parent?.isPrivate); useEffect(() => { telemetry.event( telemetryEventTypes.pageView, collectPageParameters("/team/[slug]", { isTeamBooking: true }) ); }, [telemetry, pathname]); if (considerUnpublished) { const teamSlug = team.slug || metadata?.requestedSlug; const parentSlug = team.parent?.slug || team.parent?.requestedSlug; // Show unpublished state for parent Organization itself, if the team is a subteam(team.parent is NOT NULL) const slugPropertyName = team.parent || team.isOrganization ? "orgSlug" : "teamSlug"; return (
); } // slug is a route parameter, we don't want to forward it to the next route const { slug: _slug, orgSlug: _orgSlug, user: _user, ...queryParamsToForward } = routerQuery; const EventTypes = ({ eventTypes }: { eventTypes: NonNullable<(typeof team)["eventTypes"]> }) => ( ); const SubTeams = () => team.children.length ? ( ) : (

{` ${t("org_no_teams_yet")}`}

{t("org_no_teams_yet_description")}

); const profileImageSrc = getOrgOrTeamAvatar(team); return ( <>

{team.parent && `${team.parent.name} `} {teamName}

{!isBioEmpty && ( <>
)}
{team.isOrganization ? ( !teamOrOrgIsPrivate ? ( ) : (

{t("you_cannot_see_teams_of_org")}

) ) : ( <> {(showMembers.isOn || !team.eventTypes?.length) && (teamOrOrgIsPrivate ? (

{t("you_cannot_see_team_members")}

) : ( ))} {!showMembers.isOn && team.eventTypes && team.eventTypes.length > 0 && (
{/* Hide "Book a team member button when team is private or hideBookATeamMember is true" */} {!team.hideBookATeamMember && !teamOrOrgIsPrivate && (
)}
)} )}
); } export default TeamPage;