import React, { MutableRefObject } from "react"; import { observer } from "mobx-react"; import { MoreVertical } from "lucide-react"; // components import { MultipleSelectEntityAction } from "@/components/core"; import { useGanttChart } from "@/components/gantt-chart/hooks"; import { IssueGanttSidebarBlock } from "@/components/issues"; // helpers import { cn } from "@/helpers/common.helper"; import { findTotalDaysInRange } from "@/helpers/date-time.helper"; // hooks import { useIssueDetail } from "@/hooks/store"; import { TSelectionHelper } from "@/hooks/use-multiple-select"; // constants import { BLOCK_HEIGHT, GANTT_SELECT_GROUP } from "../../constants"; // types import { IGanttBlock } from "../../types"; type Props = { block: IGanttBlock; enableReorder: boolean; enableSelection: boolean; isDragging: boolean; dragHandleRef: MutableRefObject; selectionHelpers?: TSelectionHelper; }; export const IssuesSidebarBlock = observer((props: Props) => { const { block, enableReorder, enableSelection, isDragging, dragHandleRef, selectionHelpers } = props; // store hooks const { updateActiveBlockId, isBlockActive } = useGanttChart(); const { getIsIssuePeeked } = useIssueDetail(); const duration = findTotalDaysInRange(block.start_date, block.target_date); const isIssueSelected = selectionHelpers?.getIsEntitySelected(block.id); const isIssueFocused = selectionHelpers?.getIsEntityActive(block.id); const isBlockHoveredOn = isBlockActive(block.id); return (
updateActiveBlockId(block.id)} onMouseLeave={() => updateActiveBlockId(null)} >
{enableReorder && ( )} {enableSelection && selectionHelpers && ( )}
{duration && (
{duration} day{duration > 1 ? "s" : ""}
)}
); });