import { useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Icon } from "@calcom/ui/Icon"; import { Button } from "@calcom/ui/components/button"; import { Shell } from "@calcom/ui/v2"; import { Alert } from "@calcom/ui/v2/core/Alert"; import EmptyScreen from "@calcom/ui/v2/core/EmptyScreen"; import SkeletonLoaderTeamList from "@components/team/SkeletonloaderTeamList"; import TeamCreateModal from "@components/team/TeamCreateModal"; import TeamList from "@components/team/TeamList"; function Teams() { const { t } = useLocale(); const [showCreateTeamModal, setShowCreateTeamModal] = useState(false); const [errorMessage, setErrorMessage] = useState(""); const { data, isLoading } = trpc.useQuery(["viewer.teams.list"], { onError: (e) => { setErrorMessage(e.message); }, }); const teams = data?.filter((m) => m.accepted) || []; const invites = data?.filter((m) => !m.accepted) || []; return ( setShowCreateTeamModal(true)}> {t("new")} }> <> {!!errorMessage && } {showCreateTeamModal && ( setShowCreateTeamModal(false)} /> )} {invites.length > 0 && (

{t("open_invitations")}

)} {isLoading && } {!teams.length && !isLoading && ( setShowCreateTeamModal(true)}> {t("create_team")} } buttonOnClick={() => setShowCreateTeamModal(true)} /> )} {teams.length > 0 && }
); } Teams.requiresLicense = false; export default Teams;