import { GarbageIcon } from "@/components/icons/GarbageIcon"; import { Button } from "@/components/ui/button"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { ReloadIcon } from "@radix-ui/react-icons"; import { useEffect, useState } from "react"; import { useDeleteFolderMutation } from "../hooks/useFolderMutations"; type Props = { folderId: string; folderTitle: string; }; function DeleteFolderButton({ folderId, folderTitle }: Props) { const [deleteOption, setDeleteOption] = useState< "folder_only" | "folder_and_workflows" >("folder_only"); const [isDialogOpen, setIsDialogOpen] = useState(false); const { mutate: deleteFolder, isPending: isDeleteFolderPending, isSuccess: isDeleteFolderSuccess, } = useDeleteFolderMutation(); // Close dialog when deletion succeeds useEffect(() => { if (isDeleteFolderSuccess) setIsDialogOpen(false); }, [isDeleteFolderSuccess]); const handleDelete = () => { const deleteWorkflows = deleteOption === "folder_and_workflows"; deleteFolder({ folderId, folderTitle, deleteWorkflows }); }; return ( Delete Folder e.preventDefault()}> Delete Folder: {folderTitle} Choose how you want to delete this folder. setDeleteOption(value as typeof deleteOption) } >
); } export { DeleteFolderButton };