import React, { useState } from "react"; import { observer } from "mobx-react-lite"; // hooks // components import { CycleDropdown } from "components/dropdowns"; // ui // helpers import { cn } from "helpers/common.helper"; import { useIssueDetail } from "hooks/store"; // types import type { TIssueOperations } from "./root"; type TIssueCycleSelect = { className?: string; workspaceSlug: string; projectId: string; issueId: string; issueOperations: TIssueOperations; disabled?: boolean; }; export const IssueCycleSelect: React.FC = observer((props) => { const { className = "", workspaceSlug, projectId, issueId, issueOperations, disabled = false } = props; // states const [isUpdating, setIsUpdating] = useState(false); // store hooks const { issue: { getIssueById }, } = useIssueDetail(); // derived values const issue = getIssueById(issueId); const disableSelect = disabled || isUpdating; const handleIssueCycleChange = async (cycleId: string | null) => { if (!issue || issue.cycle_id === cycleId) return; setIsUpdating(true); if (cycleId) await issueOperations.addIssueToCycle?.(workspaceSlug, projectId, cycleId, [issueId]); else await issueOperations.removeIssueFromCycle?.(workspaceSlug, projectId, issue.cycle_id ?? "", issueId); setIsUpdating(false); }; return (
); });