import { useState, useRef } from "react"; import { observer } from "mobx-react"; import { MoreHorizontal } from "lucide-react"; import { TIssue } from "@plane/types"; // components import { Tooltip, ControlLink } from "@plane/ui"; // hooks import { cn } from "@/helpers/common.helper"; import { useApplication, useIssueDetail, useProject, useProjectState } from "@/hooks/store"; import useOutsideClickDetector from "@/hooks/use-outside-click-detector"; // helpers // types import { usePlatformOS } from "@/hooks/use-platform-os"; type Props = { issue: TIssue; quickActions: (issue: TIssue, customActionButton?: React.ReactElement) => React.ReactNode; isDragging?: boolean; }; export const CalendarIssueBlock: React.FC = observer((props) => { const { issue, quickActions, isDragging = false } = props; // hooks const { router: { workspaceSlug, projectId }, } = useApplication(); const { getProjectIdentifierById } = useProject(); const { getProjectStates } = useProjectState(); const { peekIssue, setPeekIssue } = useIssueDetail(); const { isMobile } = usePlatformOS(); // states const [isMenuActive, setIsMenuActive] = useState(false); const menuActionRef = useRef(null); const stateColor = getProjectStates(issue?.project_id)?.find((state) => state?.id == issue?.state_id)?.color || ""; const handleIssuePeekOverview = (issue: TIssue) => workspaceSlug && issue && issue.project_id && issue.id && setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); useOutsideClickDetector(menuActionRef, () => setIsMenuActive(false)); const customActionButton = (
setIsMenuActive(!isMenuActive)} >
); return ( handleIssuePeekOverview(issue)} className="w-full cursor-pointer text-sm text-custom-text-100" disabled={!!issue?.tempId} > <> {issue?.tempId !== undefined && (
)}
{getProjectIdentifierById(issue?.project_id)}-{issue.sequence_id}
{issue.name}
{ e.preventDefault(); e.stopPropagation(); }} > {quickActions(issue, customActionButton)}
); });