import { Fragment, useRef, useState } from "react"; import { Check, GripVertical, MoveRight, Pencil, Trash2, X } from "lucide-react"; import { Select } from "@headlessui/react"; import { Draggable } from "@plane/ui"; import { InlineEdit } from "./inline-editable"; import { TEstimatePointsObject } from "../types"; type Props = { item: TEstimatePointsObject; deleteItem: () => void; }; const EstimateItem = ({ item, deleteItem }: Props) => { const { value, id } = item; const inputRef = useRef(null); const [showDeleteUI, setShowDeleteUI] = useState(false); const [isEditing, setIsEditing] = useState(false); const handleDelete = () => { if (id) { setShowDeleteUI(true); } else { deleteItem(); } }; const handleEdit = () => { setIsEditing(true); setTimeout(() => { inputRef.current?.focus(); inputRef.current?.select(); }); }; const handleSave = () => { if (id) { // Make the api call to save the estimate point // Show a spinner setIsEditing(false); } }; return ( {isEditing && (
{}} className="border rounded-md border-custom-border-300 p-3 flex-grow" ref={inputRef} />
setIsEditing(false)} />
)} {!isEditing && (
{!showDeleteUI ? : value} {showDeleteUI && ( setShowDeleteUI(false)} /> )}
{!showDeleteUI && }
)}
); }; export { EstimateItem };