import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { Command } from "cmdk"; // hooks import { useProjectState, useIssues } from "hooks/store"; // ui import { Spinner, StateGroupIcon } from "@plane/ui"; // icons import { Check } from "lucide-react"; // types import { TIssue } from "@plane/types"; import { EIssuesStoreType } from "constants/issue"; type Props = { closePalette: () => void; issue: TIssue; }; export const ChangeIssueState: React.FC = observer((props) => { const { closePalette, issue } = props; // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // store hooks const { issues: { updateIssue }, } = useIssues(EIssuesStoreType.PROJECT); const { projectStates } = useProjectState(); const submitChanges = async (formData: Partial) => { if (!workspaceSlug || !projectId || !issue) return; const payload = { ...formData }; await updateIssue(workspaceSlug.toString(), projectId.toString(), issue.id, payload).catch((e) => { console.error(e); }); }; const handleIssueState = (stateId: string) => { submitChanges({ state_id: stateId }); closePalette(); }; return ( <> {projectStates ? ( projectStates.length > 0 ? ( projectStates.map((state) => ( handleIssueState(state.id)} className="focus:outline-none">

{state.name}

{state.id === issue.state_id && }
)) ) : (
No states found
) ) : ( )} ); });