import React, { useEffect, useState } from "react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; import { AlertTriangle } from "lucide-react"; // store hooks import { Button, TOAST_TYPE, setToast } from "@plane/ui"; import { useEstimate } from "hooks/store"; // types import { IEstimate } from "@plane/types"; // 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(); const handleEstimateDelete = () => { if (!workspaceSlug || !projectId) return; // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain 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; setToast({ type: TOAST_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.

); });