import { useFormikContext } from 'formik'; import { useState } from 'react'; import { searchUserAccounts } from '@/api/admin/users'; import SearchableSelect, { Option } from '@/components/elements/SearchableSelect'; import type { User } from '@definitions/admin'; export default ({ selected }: { selected?: User }) => { const { setFieldValue } = useFormikContext(); const [user, setUser] = useState(selected || null); const [users, setUsers] = useState(null); const onSearch = async (query: string) => { setUsers(await searchUserAccounts({ filters: { username: query, email: query } })); }; const onSelect = (user: User | null) => { console.log(user); setUser(user); setFieldValue('ownerId', user?.id || null); }; const getSelectedText = (user: User | null): string => user?.email || ''; return ( {users?.map(d => ( ))} ); };