import React, { useState } from "react"; import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { Dialog, Transition } from "@headlessui/react"; // hooks import { useApplication, useProject, useWorkspace } from "hooks/store"; import useToast from "hooks/use-toast"; // icons import { AlertTriangle } from "lucide-react"; // ui import { Button } from "@plane/ui"; // types import type { IInboxIssue } from "@plane/types"; import { useInboxIssues } from "hooks/store/use-inbox-issues"; type Props = { data: IInboxIssue; isOpen: boolean; onClose: () => void; }; export const DeleteInboxIssueModal: React.FC = observer(({ isOpen, onClose, data }) => { // states const [isDeleting, setIsDeleting] = useState(false); // router const router = useRouter(); const { workspaceSlug, projectId, inboxId } = router.query; // store hooks const { deleteIssue } = useInboxIssues(); const { eventTracker: { postHogEventTracker }, } = useApplication(); const { currentWorkspace } = useWorkspace(); const { getProjectById } = useProject(); const { setToastAlert } = useToast(); const handleClose = () => { setIsDeleting(false); onClose(); }; const handleDelete = () => { if (!workspaceSlug || !projectId || !inboxId) return; setIsDeleting(true); deleteIssue(workspaceSlug.toString(), projectId.toString(), inboxId.toString(), data.issue_inbox[0].id) .then(() => { setToastAlert({ type: "success", title: "Success!", message: "Issue deleted successfully.", }); postHogEventTracker( "ISSUE_DELETED", { state: "SUCCESS", }, { isGrouping: true, groupType: "Workspace_metrics", groupId: currentWorkspace?.id!, } ); // remove inboxIssueId from the url router.push({ pathname: `/${workspaceSlug}/projects/${projectId}/inbox/${inboxId}`, }); handleClose(); }) .catch(() => { setToastAlert({ type: "error", title: "Error!", message: "Issue could not be deleted. Please try again.", }); postHogEventTracker( "ISSUE_DELETED", { state: "FAILED", }, { isGrouping: true, groupType: "Workspace_metrics", groupId: currentWorkspace?.id!, } ); }) .finally(() => setIsDeleting(false)); }; return (

Delete Issue

Are you sure you want to delete issue{" "} {getProjectById(data?.project_id)?.identifier}-{data?.sequence_id} {""}? The issue will only be deleted from the inbox and this action cannot be undone.

); });