import React from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { Control, Controller } from "react-hook-form"; // constants import { RectangleGroupIcon } from "@heroicons/react/24/outline"; // services import modulesService from "services/modules.service"; // ui import { Spinner, CustomSelect } from "components/ui"; // icons // types import { IIssue, IModule } from "types"; import { MODULE_LIST } from "constants/fetch-keys"; type Props = { control: Control; handleModuleChange: (module: IModule) => void; }; const SelectModule: React.FC = ({ control, handleModuleChange }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { data: modules } = useSWR( workspaceSlug && projectId ? MODULE_LIST(projectId as string) : null, workspaceSlug && projectId ? () => modulesService.getModules(workspaceSlug as string, projectId as string) : null ); return (

Module

( {value ? modules?.find((m) => m.id === value?.module_detail.id)?.name : "None"} } value={value} onChange={(value: any) => { handleModuleChange(modules?.find((m) => m.id === value) as any); }} > {modules ? ( modules.length > 0 ? ( modules.map((option) => ( {option.name} )) ) : (
No cycles found
) ) : ( )}
)} />
); }; export default SelectModule;