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 { useCycle } from "@/hooks/store"; type Props = { workspaceSlug: string; projectId: string; cycleId: string; handleClose: () => void; isOpen: boolean; onSubmit?: () => Promise; }; export const ArchiveCycleModal: React.FC = (props) => { const { workspaceSlug, projectId, cycleId, isOpen, handleClose } = props; // router const router = useRouter(); // states const [isArchiving, setIsArchiving] = useState(false); // store hooks const { getCycleNameById, archiveCycle } = useCycle(); const cycleName = getCycleNameById(cycleId); const onClose = () => { setIsArchiving(false); handleClose(); }; const handleArchiveCycle = async () => { setIsArchiving(true); await archiveCycle(workspaceSlug, projectId, cycleId) .then(() => { setToast({ type: TOAST_TYPE.SUCCESS, title: "Archive success", message: "Your archives can be found in project archives.", }); onClose(); router.push(`/${workspaceSlug}/projects/${projectId}/cycles`); }) .catch(() => setToast({ type: TOAST_TYPE.ERROR, title: "Error!", message: "Cycle could not be archived. Please try again.", }) ) .finally(() => setIsArchiving(false)); }; return (

Archive cycle {cycleName}

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

); };