import { Fragment, useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; import { AlertTriangle } from "lucide-react"; // hooks import { useEventTracker, useCycle } from "hooks/store"; import useToast from "hooks/use-toast"; // components import { Button } from "@plane/ui"; // types import { ICycle } from "@plane/types"; interface ICycleDelete { cycle: ICycle; isOpen: boolean; handleClose: () => void; workspaceSlug: string; projectId: string; } export const CycleDeleteModal: React.FC = observer((props) => { const { isOpen, handleClose, cycle, workspaceSlug, projectId } = props; // states const [loader, setLoader] = useState(false); // router const router = useRouter(); const { cycleId, peekCycle } = router.query; // store hooks const { captureCycleEvent } = useEventTracker(); const { deleteCycle } = useCycle(); // toast alert const { setToastAlert } = useToast(); const formSubmit = async () => { if (!cycle) return; setLoader(true); try { await deleteCycle(workspaceSlug, projectId, cycle.id) .then(() => { setToastAlert({ type: "success", title: "Success!", message: "Cycle deleted successfully.", }); captureCycleEvent({ eventName: "Cycle deleted", payload: { ...cycle, state: "SUCCESS" }, }); }) .catch(() => { captureCycleEvent({ eventName: "Cycle deleted", payload: { ...cycle, state: "FAILED" }, }); }); if (cycleId || peekCycle) router.push(`/${workspaceSlug}/projects/${projectId}/cycles`); handleClose(); } catch (error) { setToastAlert({ type: "error", title: "Warning!", message: "Something went wrong please try again later.", }); } setLoader(false); }; return (
Delete Cycle

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

); });