import { useFormikContext } from 'formik'; import { useState } from 'react'; import type { Node } from '@/api/admin/node'; import { searchNodes } from '@/api/admin/node'; import SearchableSelect, { Option } from '@/components/elements/SearchableSelect'; export default ({ node, setNode }: { node: Node | null; setNode: (_: Node | null) => void }) => { const { setFieldValue } = useFormikContext(); const [nodes, setNodes] = useState(null); const onSearch = async (query: string) => { setNodes(await searchNodes({ filters: { name: query } })); }; const onSelect = (node: Node | null) => { setNode(node); setFieldValue('nodeId', node?.id || null); }; const getSelectedText = (node: Node | null): string => node?.name || ''; return ( {nodes?.map(d => ( ))} ); };