import { useRouter } from "next/router"; import useSWR from "swr"; // ui import { CustomSelect } from "components/ui"; // icons import { ClipboardDocumentListIcon } from "@heroicons/react/24/outline"; // services import projectService from "services/project.service"; // fetch-keys import { PROJECTS_LIST } from "constants/fetch-keys"; export interface IssueProjectSelectProps { value: string; onChange: (value: string) => void; setActiveProject: React.Dispatch>; } export const IssueProjectSelect: React.FC = ({ value, onChange, setActiveProject, }) => { const router = useRouter(); const { workspaceSlug } = router.query; // Fetching Projects List const { data: projects } = useSWR( workspaceSlug ? PROJECTS_LIST(workspaceSlug as string) : null, () => (workspaceSlug ? projectService.getProjects(workspaceSlug as string) : null) ); return ( {projects?.find((i) => i.id === value)?.identifier ?? "Project"} } onChange={(val: string) => { onChange(val); setActiveProject(val); }} noChevron > {projects ? ( projects.length > 0 ? ( projects.map((project) => ( <>{project.name} )) ) : (

No projects found!

) ) : (
Loading...
)}
); };