import { useEffect, useState, Fragment } from "react"; import { Dialog, Transition } from "@headlessui/react"; import { AlertTriangle } from "lucide-react"; // ui import { Button } from "@plane/ui"; // hooks import useToast from "hooks/use-toast"; // types import { useIssues } from "hooks/store/use-issues"; import { TIssue } from "@plane/types"; import { useProject } from "hooks/store"; type Props = { isOpen: boolean; handleClose: () => void; dataId?: string | null | undefined; data?: TIssue; onSubmit?: () => Promise; }; export const DeleteIssueModal: React.FC = (props) => { const { dataId, data, isOpen, handleClose, onSubmit } = props; const { issueMap } = useIssues(); const [isDeleteLoading, setIsDeleteLoading] = useState(false); const { setToastAlert } = useToast(); // hooks const { getProjectById } = useProject(); useEffect(() => { setIsDeleteLoading(false); }, [isOpen]); if (!dataId && !data) return null; const issue = data ? data : issueMap[dataId!]; const onClose = () => { setIsDeleteLoading(false); handleClose(); }; const handleIssueDelete = async () => { setIsDeleteLoading(true); if (onSubmit) await onSubmit() .then(() => { onClose(); }) .catch(() => { setToastAlert({ title: "Error", type: "error", message: "Failed to delete issue", }); }) .finally(() => setIsDeleteLoading(false)); }; return (

Delete Issue

Are you sure you want to delete issue{" "} {getProjectById(issue?.project_id)?.identifier}-{issue?.sequence_id} {""}? All of the data related to the issue will be permanently removed. This action cannot be undone.

); };