import React, { useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; // store import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; // icons import { AlertTriangle } from "lucide-react"; // hooks import useToast from "hooks/use-toast"; // ui import { Button } from "@plane/ui"; // types import type { IState } from "types"; import { trackEvent } from "helpers/event-tracker.helper"; type Props = { isOpen: boolean; onClose: () => void; data: IState | null; }; export const DeleteStateModal: React.FC = observer((props) => { const { isOpen, onClose, data } = props; // router const router = useRouter(); const { workspaceSlug } = router.query; // store const { projectState: projectStateStore } = useMobxStore(); // states const [isDeleteLoading, setIsDeleteLoading] = useState(false); const { setToastAlert } = useToast(); const handleClose = () => { onClose(); setIsDeleteLoading(false); }; const handleDeletion = async () => { if (!workspaceSlug || !data) return; setIsDeleteLoading(true); await projectStateStore .deleteState(workspaceSlug.toString(), data.project, data.id) .then((res) => { trackEvent( 'STATE_DELETE', ) handleClose(); }) .catch((err) => { if (err.status === 400) setToastAlert({ type: "error", title: "Error!", message: "This state contains some issues within it, please move them to some other state to delete this state.", }); else setToastAlert({ type: "error", title: "Error!", message: "State could not be deleted. Please try again.", }); }) .finally(() => { setIsDeleteLoading(false); }); }; return (
Delete State

Are you sure you want to delete state-{" "} {data?.name}? All of the data related to the state will be permanently removed. This action cannot be undone.

); });