import React, { useEffect, 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"; // store hooks import { useEstimate } from "hooks/store"; import useToast from "hooks/use-toast"; // types import { IEstimate } from "@plane/types"; // ui import { Button } from "@plane/ui"; type Props = { isOpen: boolean; data: IEstimate | null; handleClose: () => void; }; export const DeleteEstimateModal: React.FC = observer((props) => { const { isOpen, handleClose, data } = props; // states const [isDeleteLoading, setIsDeleteLoading] = useState(false); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // store hooks const { deleteEstimate } = useEstimate(); // toast alert const { setToastAlert } = useToast(); const handleEstimateDelete = () => { if (!workspaceSlug || !projectId) return; const estimateId = data?.id!; deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId) .then(() => { setIsDeleteLoading(false); handleClose(); }) .catch((err) => { const error = err?.error; const errorString = Array.isArray(error) ? error[0] : error; setToastAlert({ type: "error", title: "Error!", message: errorString ?? "Estimate could not be deleted. Please try again", }); }); }; useEffect(() => { setIsDeleteLoading(false); }, [isOpen]); const onClose = () => { setIsDeleteLoading(false); handleClose(); }; return (

Delete Estimate

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

); });