import React, { useEffect, useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; // services import { IssueDraftService } from "services/issue"; // hooks import useToast from "hooks/use-toast"; // icons import { AlertTriangle } from "lucide-react"; // ui import { Button } from "@plane/ui"; // types import type { TIssue } from "@plane/types"; import { useProject } from "hooks/store"; type Props = { isOpen: boolean; handleClose: () => void; data: TIssue | null; onSubmit?: () => Promise | void; }; const issueDraftService = new IssueDraftService(); export const DeleteDraftIssueModal: React.FC = (props) => { const { isOpen, handleClose, data, onSubmit } = props; // states const [isDeleteLoading, setIsDeleteLoading] = useState(false); // router const router = useRouter(); const { workspaceSlug } = router.query; // toast alert const { setToastAlert } = useToast(); // hooks const { getProjectById } = useProject(); useEffect(() => { setIsDeleteLoading(false); }, [isOpen]); const onClose = () => { setIsDeleteLoading(false); handleClose(); }; const handleDeletion = async () => { if (!workspaceSlug || !data) return; setIsDeleteLoading(true); await issueDraftService .deleteDraftIssue(workspaceSlug.toString(), data.project_id, data.id) .then(() => { setIsDeleteLoading(false); handleClose(); setToastAlert({ title: "Success", message: "Draft Issue deleted successfully", type: "success", }); }) .catch((error) => { console.error(error); handleClose(); setToastAlert({ title: "Error", message: "Something went wrong", type: "error", }); setIsDeleteLoading(false); }); if (onSubmit) await onSubmit(); }; return (

Delete Draft Issue

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

); };