import React, { useEffect, useRef, useState } from "react"; // next import { useRouter } from "next/router"; // swr import { mutate } from "swr"; // headless ui import { Dialog, Transition } from "@headlessui/react"; // services import cycleService from "services/cycles.service"; // hooks import useToast from "hooks/use-toast"; // ui import { Button } from "components/ui"; // icons import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; // types import type { ICycle } from "types"; type TConfirmCycleDeletionProps = { isOpen: boolean; setIsOpen: React.Dispatch>; data?: ICycle; }; // fetch-keys import { CYCLE_LIST } from "constants/fetch-keys"; export const DeleteCycleModal: React.FC = ({ isOpen, setIsOpen, data, }) => { const cancelButtonRef = useRef(null); const [isDeleteLoading, setIsDeleteLoading] = useState(false); const router = useRouter(); const { workspaceSlug } = router.query; const { setToastAlert } = useToast(); const handleClose = () => { setIsOpen(false); setIsDeleteLoading(false); }; const handleDeletion = async () => { setIsDeleteLoading(true); if (!data || !workspaceSlug) return; await cycleService .deleteCycle(workspaceSlug as string, data.project, data.id) .then(() => { mutate( CYCLE_LIST(data.project), (prevData) => prevData?.filter((cycle) => cycle.id !== data?.id), false ); handleClose(); setToastAlert({ title: "Success", type: "success", message: "Cycle deleted successfully", }); }) .catch((error) => { console.log(error); setIsDeleteLoading(false); }); }; return (
Delete Cycle

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

); };