"use client"; import { useState, Fragment } from "react"; import { useRouter } from "next/navigation"; 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 handleArchiveModule = 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}/modules`); }) .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.

); };