import { useEffect, useState, Fragment } from "react"; import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { Dialog, Transition } from "@headlessui/react"; import { AlertTriangle } from "lucide-react"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // hooks import useToast from "hooks/use-toast"; // ui import { Button } from "@plane/ui"; // types import type { IIssue } from "types"; type Props = { isOpen: boolean; handleClose: () => void; data: IIssue; onSubmit?: () => Promise; }; export const DeleteArchivedIssueModal: React.FC = observer((props) => { const { data, isOpen, handleClose, onSubmit } = props; const router = useRouter(); const { workspaceSlug } = router.query; const { setToastAlert } = useToast(); const { archivedIssueDetail: archivedIssueDetailStore } = useMobxStore(); const [isDeleteLoading, setIsDeleteLoading] = useState(false); useEffect(() => { setIsDeleteLoading(false); }, [isOpen]); const onClose = () => { setIsDeleteLoading(false); handleClose(); }; const handleIssueDelete = async () => { if (!workspaceSlug) return; setIsDeleteLoading(true); await archivedIssueDetailStore .deleteArchivedIssue(workspaceSlug.toString(), data.project, data.id) .then(() => { if (onSubmit) onSubmit(); }) .catch((err) => { const error = err?.detail; const errorString = Array.isArray(error) ? error[0] : error; setToastAlert({ title: "Error", type: "error", message: errorString || "Something went wrong.", }); }) .finally(() => { setIsDeleteLoading(false); onClose(); }); }; return (

Delete Archived Issue

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

); });