import React from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { observer } from "mobx-react-lite"; // store import { useMobxStore } from "lib/mobx/store-provider"; // ui import { CustomSearchSelect, DoubleCircleIcon, StateGroupIcon } from "@plane/ui"; // icons import { Plus } from "lucide-react"; type Props = { setIsOpen: React.Dispatch>; value: string; onChange: (value: string) => void; projectId: string; }; export const IssueStateSelect: React.FC = observer((props) => { const { setIsOpen, value, onChange, projectId } = props; // states const router = useRouter(); const { workspaceSlug } = router.query; const { projectState: { states: projectStates, fetchProjectStates }, } = useMobxStore(); useSWR( workspaceSlug && projectId ? `STATES_LIST_${projectId.toUpperCase()}` : null, workspaceSlug && projectId ? () => fetchProjectStates(workspaceSlug.toString(), projectId) : null ); const states = projectStates?.[projectId] || []; const options = states?.map((state) => ({ value: state.id, query: state.name, content: (
{state.name}
), })); const selectedOption = states?.find((s) => s.id === value); const currentDefaultState = states?.find((s) => s.default); return ( {selectedOption ? ( ) : currentDefaultState ? ( ) : ( )} {selectedOption?.name ? selectedOption.name : currentDefaultState?.name ?? State} } footerOption={ } noChevron /> ); });