// react import React from "react"; // next import { useRouter } from "next/router"; // swr import useSWR from "swr"; // react hook form import { Controller } from "react-hook-form"; import type { Control } from "react-hook-form"; // services import projectService from "lib/services/project.service"; // headless ui import { Listbox, Transition } from "@headlessui/react"; // icons import { ClipboardDocumentListIcon } from "@heroicons/react/24/outline"; // ui import { Spinner } from "ui"; // fetch-keys import { PROJECTS_LIST } from "constants/fetch-keys"; // types import type { IIssue } from "types"; type Props = { control: Control; activeProject: string; setActiveProject: React.Dispatch>; }; const SelectProject: React.FC = ({ control, setActiveProject }) => { const router = useRouter(); const { workspaceSlug } = router.query; const { data: projects } = useSWR( workspaceSlug ? PROJECTS_LIST(workspaceSlug as string) : null, () => (workspaceSlug ? projectService.getProjects(workspaceSlug as string) : null) ); return ( <> ( { onChange(val); setActiveProject(val); }} > {({ open }) => ( <>
{projects?.find((i) => i.id === value)?.identifier ?? "Project"}
{projects ? ( projects.length > 0 ? ( projects.map((project) => ( `${ active ? "bg-indigo-50" : "" } cursor-pointer select-none p-2 text-gray-900` } value={project.id} > {({ selected, active }) => ( <> {project.name} )} )) ) : (

No projects found!

) ) : (
)}
)}
)} >
); }; export default SelectProject;