"use client"; import { FC, useState } from "react"; import { observer } from "mobx-react"; // ui import { Button, EModalPosition, EModalWidth, ModalCore, TOAST_TYPE, setToast } from "@plane/ui"; // hooks import { useEstimate, useProject, useProjectEstimates } from "@/hooks/store"; type TDeleteEstimateModal = { workspaceSlug: string; projectId: string; estimateId: string | undefined; isOpen: boolean; handleClose: () => void; }; export const DeleteEstimateModal: FC = observer((props) => { // props const { workspaceSlug, projectId, estimateId, isOpen, handleClose } = props; // hooks const { areEstimateEnabledByProjectId, deleteEstimate } = useProjectEstimates(); const { asJson: estimate } = useEstimate(estimateId); const { updateProject } = useProject(); // states const [buttonLoader, setButtonLoader] = useState(false); const handleDeleteEstimate = async () => { try { if (!workspaceSlug || !projectId || !estimateId) return; setButtonLoader(true); await deleteEstimate(workspaceSlug, projectId, estimateId); if (areEstimateEnabledByProjectId(projectId)) { await updateProject(workspaceSlug, projectId, { estimate: null }); } setButtonLoader(false); setToast({ type: TOAST_TYPE.SUCCESS, title: "Estimate deleted", message: "Estimate has been removed from your project.", }); handleClose(); } catch (error) { setButtonLoader(false); setToast({ type: TOAST_TYPE.ERROR, title: "Estimate creation failed", message: "We were unable to delete the estimate, please try again.", }); } }; return (
{/* heading */}
Delete Estimate System
{/* estimate steps */}
Deleting the estimate {estimate?.name}  system will remove it from all issues permanently. This action cannot be undone. If you add estimates again, you will need to update all the issues.
); });