import React, { useCallback } from "react"; import { observer } from "mobx-react"; import { useParams, usePathname } from "next/navigation"; // types import { TIssue } from "@plane/types"; // components import { CycleDropdown } from "@/components/dropdowns"; // constants import { EIssuesStoreType } from "@/constants/issue"; // hooks import { useEventTracker, useIssues } from "@/hooks/store"; type Props = { issue: TIssue; onClose: () => void; disabled: boolean; }; export const SpreadsheetCycleColumn: React.FC = observer((props) => { const { issue, disabled, onClose } = props; // router const { workspaceSlug } = useParams(); const pathname = usePathname(); // hooks const { captureIssueEvent } = useEventTracker(); const { issues: { addCycleToIssue, removeCycleFromIssue }, } = useIssues(EIssuesStoreType.CYCLE); const handleCycle = useCallback( async (cycleId: string | null) => { if (!workspaceSlug || !issue || issue.cycle_id === cycleId) return; if (cycleId) await addCycleToIssue(workspaceSlug.toString(), issue.project_id, cycleId, issue.id); else await removeCycleFromIssue(workspaceSlug.toString(), issue.project_id, issue.id); captureIssueEvent({ eventName: "Issue updated", payload: { ...issue, cycle_id: cycleId, element: "Spreadsheet layout", }, updates: { changed_property: "cycle", change_details: { cycle_id: cycleId } }, path: pathname, }); }, [workspaceSlug, issue, addCycleToIssue, removeCycleFromIssue, captureIssueEvent, pathname] ); return (
); });