import { MembershipRole } from "@prisma/client"; import Link from "next/link"; import classNames from "@calcom/lib/classNames"; import { getPlaceholderAvatar } from "@calcom/lib/getPlaceholderAvatar"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import { Icon } from "@calcom/ui/Icon"; import Button from "@calcom/ui/v2/core/Button"; import ButtonGroup from "@calcom/ui/v2/core/ButtonGroup"; import ConfirmationDialogContent from "@calcom/ui/v2/core/ConfirmationDialogContent"; import { Dialog, DialogTrigger } from "@calcom/ui/v2/core/Dialog"; import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, DropdownItem, } from "@calcom/ui/v2/core/Dropdown"; import { Tooltip } from "@calcom/ui/v2/core/Tooltip"; import showToast from "@calcom/ui/v2/core/notifications"; import Avatar from "@components/ui/Avatar"; import { TeamRole } from "./TeamPill"; interface Props { team: inferQueryOutput<"viewer.teams.list">[number]; key: number; onActionSelect: (text: string) => void; isLoading?: boolean; hideDropdown: boolean; setHideDropdown: (value: boolean) => void; } export default function TeamListItem(props: Props) { const { t } = useLocale(); const utils = trpc.useContext(); const team = props.team; const acceptOrLeaveMutation = trpc.useMutation("viewer.teams.acceptOrLeave", { onSuccess: () => { utils.invalidateQueries(["viewer.teams.list"]); }, }); function acceptOrLeave(accept: boolean) { acceptOrLeaveMutation.mutate({ teamId: team?.id as number, accept, }); } const acceptInvite = () => acceptOrLeave(true); const declineInvite = () => acceptOrLeave(false); const isOwner = props.team.role === MembershipRole.OWNER; const isInvitee = !props.team.accepted; const isAdmin = props.team.role === MembershipRole.OWNER || props.team.role === MembershipRole.ADMIN; const { hideDropdown, setHideDropdown } = props; if (!team) return <>>; const teamInfo = (