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"; // hooks import useToast from "hooks/use-toast"; import { useIssues, useProject } from "hooks/store"; // ui import { Button } from "@plane/ui"; // types import type { TIssue } from "@plane/types"; import { EIssuesStoreType } from "constants/issue"; type Props = { isOpen: boolean; handleClose: () => void; data: TIssue; 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 { getProjectById } = useProject(); const { issues: { removeIssue }, } = useIssues(EIssuesStoreType.ARCHIVED); const [isDeleteLoading, setIsDeleteLoading] = useState(false); useEffect(() => { setIsDeleteLoading(false); }, [isOpen]); const onClose = () => { setIsDeleteLoading(false); handleClose(); }; const handleIssueDelete = async () => { if (!workspaceSlug) return; setIsDeleteLoading(true); await removeIssue(workspaceSlug.toString(), data.project_id, 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{" "} {getProjectById(data?.project_id)?.identifier}-{data?.sequence_id} {""}? All of the data related to the archived issue will be permanently removed. This action cannot be undone.

); });