import { useEffect, useState, Fragment } from "react"; import { Dialog, Transition } from "@headlessui/react"; import { AlertTriangle } from "lucide-react"; // ui import { Button, TOAST_TYPE, setToast } from "@plane/ui"; // types import { TIssue } from "@plane/types"; 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 [isDeleting, setIsDeleting] = useState(false); // hooks const { getProjectById } = useProject(); useEffect(() => { setIsDeleting(false); }, [isOpen]); if (!dataId && !data) return null; const issue = data ? data : issueMap[dataId!]; const onClose = () => { setIsDeleting(false); handleClose(); }; const handleIssueDelete = async () => { setIsDeleting(true); if (onSubmit) await onSubmit() .then(() => { onClose(); }) .catch(() => { setToast({ title: "Error", type: TOAST_TYPE.ERROR, message: "Failed to delete issue", }); }) .finally(() => setIsDeleting(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.

); };