import { FC } from "react"; import { observer } from "mobx-react"; import { Pen } from "lucide-react"; // helpers import { cn } from "@/helpers/common.helper"; // hooks import { useEstimate, useProjectEstimates } from "@/hooks/store"; type TEstimateListItem = { estimateId: string; isAdmin: boolean; isEstimateEnabled: boolean; isEditable: boolean; onEditClick?: (estimateId: string) => void; }; export const EstimateListItem: FC = observer((props) => { const { estimateId, isAdmin, isEstimateEnabled, isEditable, onEditClick } = props; // hooks const { estimateById } = useProjectEstimates(); const { estimatePointIds, estimatePointById } = useEstimate(estimateId); const currentEstimate = estimateById(estimateId); // derived values const estimatePointValues = estimatePointIds?.map((estimatePointId) => { const estimatePoint = estimatePointById(estimatePointId); if (estimatePoint) return estimatePoint.value; }); if (!currentEstimate) return <>; return (

{currentEstimate?.name}

{(estimatePointValues || [])?.join(", ")}

{isAdmin && isEditable && (
onEditClick && onEditClick(estimateId)} >
)}
); });