import { MembershipRole } from "@prisma/client"; import classNames from "@calcom/lib/classNames"; import { getPlaceholderAvatar } from "@calcom/lib/getPlaceholderAvatar"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Icon } from "@calcom/ui/Icon"; import { Avatar, Button, Dropdown, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@calcom/ui/v2"; interface Props { team: { id?: number; name?: string | null; slug?: string | null; logo?: string | null; bio?: string | null; hideBranding?: boolean | undefined; role: MembershipRole; accepted: boolean; }; key: number; onActionSelect: (text: string) => void; isLoading?: boolean; hideDropdown: boolean; setHideDropdown: (value: boolean) => void; } export default function TeamInviteListItem(props: Props) { const { t } = useLocale(); const utils = trpc.useContext(); const team = props.team; const acceptOrLeaveMutation = trpc.useMutation("viewer.teams.acceptOrLeave", { onSuccess: async () => { await utils.invalidateQueries(["viewer.teams.get"]); await 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 = (