import { FC, useState } from "react"; import { observer } from "mobx-react"; import { Info, MoveRight, Trash2, X } from "lucide-react"; import { Select } from "@headlessui/react"; import { Spinner, Tooltip } from "@plane/ui"; // helpers import { cn } from "@/helpers/common.helper"; // hooks import { useEstimate, useEstimatePoint } from "@/hooks/store"; type TEstimatePointDelete = { workspaceSlug: string; projectId: string; estimateId: string; estimatePointId: string; callback: () => void; }; export const EstimatePointDelete: FC = observer((props) => { const { workspaceSlug, projectId, estimateId, estimatePointId, callback } = props; // hooks const { asJson: estimate, deleteEstimatePoint } = useEstimate(estimateId); const { asJson: estimatePoint } = useEstimatePoint(estimateId, estimatePointId); // states const [loader, setLoader] = useState(false); const [estimateInputValue, setEstimateInputValue] = useState(undefined); const [error, setError] = useState(undefined); const handleClose = () => { setEstimateInputValue(""); callback(); }; const handleCreate = async () => { if (!workspaceSlug || !projectId || !projectId) return; try { setLoader(true); setError(undefined); await deleteEstimatePoint(workspaceSlug, projectId, estimatePointId, estimateInputValue); setLoader(false); setError(undefined); handleClose(); } catch { setLoader(false); setError("something went wrong. please try again later"); } }; // derived values const selectDropdownOptions = estimate && estimate?.points ? estimate?.points.filter((point) => point.id !== estimatePointId) : []; return (
{estimatePoint?.value}
Mark as
{error && ( <>
)}
{loader ? (
) : (
)}
); });