import { MoreVertical, Trash2 } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import type { Rkey } from "@/lib/atproto-client"; import { useDeleteCollectionListMutation } from "@/lib/collection-list-queries"; import { DeleteListDialog } from "./DeleteListDialog"; interface ListActionsMenuProps { listName: string; rkey: Rkey; } export function ListActionsMenu({ listName, rkey }: ListActionsMenuProps) { const [isOpen, setIsOpen] = useState(false); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const menuRef = useRef(null); const deleteMutation = useDeleteCollectionListMutation(rkey); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (menuRef.current && !menuRef.current.contains(event.target as Node)) { setIsOpen(false); } }; if (isOpen) { document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); } }, [isOpen]); return (
{isOpen && (
)} setShowDeleteDialog(false)} onConfirm={() => deleteMutation.mutate()} isDeleting={deleteMutation.isPending} />
); }