import { DotsHorizontalIcon, ExternalLinkIcon, LinkIcon, PencilAltIcon, TrashIcon, } from "@heroicons/react/outline"; import Link from "next/link"; import { useState } from "react"; import { useLocale } from "@lib/hooks/useLocale"; import showToast from "@lib/notification"; import { Dialog, DialogTrigger } from "@components/Dialog"; import { Tooltip } from "@components/Tooltip"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import Avatar from "@components/ui/Avatar"; import Button from "@components/ui/Button"; import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../ui/Dropdown"; interface Team { id: number; name: string | null; slug: string | null; logo: string | null; bio: string | null; role: string | null; hideBranding: boolean; prevState: null; } export default function TeamListItem(props: { onChange: () => void; key: number; team: Team; onActionSelect: (text: string) => void; }) { const [team, setTeam] = useState(props.team); const { t } = useLocale(); const acceptInvite = () => invitationResponse(true); const declineInvite = () => invitationResponse(false); const invitationResponse = (accept: boolean) => fetch("/api/user/membership", { method: accept ? "PATCH" : "DELETE", body: JSON.stringify({ teamId: props.team.id }), headers: { "Content-Type": "application/json", }, }).then(() => { // success setTeam(null); props.onChange(); }); return ( team && (
  • {props.team.name} {process.env.NEXT_PUBLIC_APP_URL}/team/{props.team.slug}
    {props.team.role === "INVITEE" && (
    )} {props.team.role === "MEMBER" && (
    )} {props.team.role === "OWNER" && (
    {t("owner")} props.onActionSelect("disband")}> {t("disband_team_confirmation_message")}
    )}
  • ) ); }