import React, { useEffect, useState } from "react"; import { useRouter } from "next/router"; import { Dialog, Transition } from "@headlessui/react"; // store import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; // hooks import useToast from "hooks/use-toast"; // types import { IEstimate } from "types"; // icons import { AlertTriangle } from "lucide-react"; // 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; // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // store const { projectEstimates: projectEstimatesStore } = useMobxStore(); // states const [isDeleteLoading, setIsDeleteLoading] = useState(false); // hooks const { setToastAlert } = useToast(); const handleEstimateDelete = () => { if (!workspaceSlug || !projectId) return; const estimateId = data?.id!; projectEstimatesStore.deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId).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.

); });