import { useState, Fragment } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; // ui import { Button, TOAST_TYPE, setToast } from "@plane/ui"; // hooks import { useModule } from "@/hooks/store"; type Props = { workspaceSlug: string; projectId: string; moduleId: string; handleClose: () => void; isOpen: boolean; onSubmit?: () => Promise; }; export const ArchiveModuleModal: React.FC = (props) => { const { workspaceSlug, projectId, moduleId, isOpen, handleClose } = props; // router const router = useRouter(); // states const [isArchiving, setIsArchiving] = useState(false); // store hooks const { getModuleNameById, archiveModule } = useModule(); const moduleName = getModuleNameById(moduleId); const onClose = () => { setIsArchiving(false); handleClose(); }; const handleArchiveIssue = async () => { setIsArchiving(true); await archiveModule(workspaceSlug, projectId, moduleId) .then(() => { setToast({ type: TOAST_TYPE.SUCCESS, title: "Archive success", message: "Your archives can be found in project archives.", }); onClose(); router.push(`/${workspaceSlug}/projects/${projectId}/archives/modules?peekModule=${moduleId}`); }) .catch(() => setToast({ type: TOAST_TYPE.ERROR, title: "Error!", message: "Module could not be archived. Please try again.", }) ) .finally(() => setIsArchiving(false)); }; return (

Archive module {moduleName}

Are you sure you want to archive the module? All your archives can be restored later.

); };