import { PlusIcon, UserGroupIcon } from "@heroicons/react/solid";
import classNames from "classnames";
import { useSession } from "next-auth/react";
import { Trans } from "next-i18next";
import { useState } from "react";
import { Alert } from "@calcom/ui/Alert";
import Button from "@calcom/ui/Button";
import { useLocale } from "@lib/hooks/useLocale";
import useMeQuery from "@lib/hooks/useMeQuery";
import { trpc } from "@lib/trpc";
import EmptyScreen from "@components/EmptyScreen";
import Loader from "@components/Loader";
import SettingsShell from "@components/SettingsShell";
import Shell from "@components/Shell";
import TeamCreateModal from "@components/team/TeamCreateModal";
import TeamList from "@components/team/TeamList";
export default function Teams() {
const { t } = useLocale();
const { status } = useSession();
const loading = status === "loading";
const [showCreateTeamModal, setShowCreateTeamModal] = useState(false);
const [errorMessage, setErrorMessage] = useState("");
const me = useMeQuery();
const { data, isLoading } = trpc.useQuery(["viewer.teams.list"], {
onError: (e) => {
setErrorMessage(e.message);
},
});
if (loading) return ;
const teams = data?.filter((m) => m.accepted) || [];
const invites = data?.filter((m) => !m.accepted) || [];
const isFreePlan = me.data?.plan === "FREE";
return (
{!!errorMessage && }
{isFreePlan && (
{t("plan_upgrade_teams")}>}
message={
You can
upgrade here
.
}
className="my-4"
/>
)}
{showCreateTeamModal && (
setShowCreateTeamModal(false)} />
)}
{invites.length > 0 && (
{t("open_invitations")}
)}
{!isLoading && !teams.length && (
)}
{teams.length > 0 && }
);
}