import React, { useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; // hooks import useToast from "hooks/use-toast"; // ui import { Button } from "@plane/ui"; // icons import { AlertTriangle } from "lucide-react"; // types import type { IModule } from "types"; import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; type Props = { data: IModule; isOpen: boolean; onClose: () => void; }; export const DeleteModuleModal: React.FC = observer((props) => { const { data, isOpen, onClose } = props; const [isDeleteLoading, setIsDeleteLoading] = useState(false); const router = useRouter(); const { workspaceSlug, projectId, moduleId, peekModule } = router.query; const { module: moduleStore, trackEvent: { postHogEventTracker }, } = useMobxStore(); const { setToastAlert } = useToast(); const handleClose = () => { onClose(); setIsDeleteLoading(false); }; const handleDeletion = async () => { if (!workspaceSlug || !projectId) return; setIsDeleteLoading(true); await moduleStore .deleteModule(workspaceSlug.toString(), projectId.toString(), data.id) .then(() => { if (moduleId || peekModule) router.push(`/${workspaceSlug}/projects/${data.project}/modules`); handleClose(); setToastAlert({ type: "success", title: "Success!", message: "Module deleted successfully.", }); postHogEventTracker("MODULE_DELETED", { state: "SUCCESS", }); }) .catch(() => { setToastAlert({ type: "error", title: "Error!", message: "Module could not be deleted. Please try again.", }); postHogEventTracker("MODULE_DELETED", { state: "FAILED", }); }) .finally(() => { setIsDeleteLoading(false); }); }; return (
Delete Module

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

); });