@@ -10,6 +10,7 @@ import { UserState } from '../../../lib/context'
10
10
import ErrorMessage from '../../lib/error' ;
11
11
import { PollyInput , SubjectType } from '../../../lib/rest/access' ;
12
12
import { useSearchPolly } from '../../../lib/rest/polly' ;
13
+ import { set } from 'lodash' ;
13
14
14
15
const tomorrow = ( ) => {
15
16
const date = new Date ( )
@@ -90,6 +91,7 @@ const AccessRequestFormV2 = ({
90
91
const [ searchText , setSearchText ] = useState ( '' )
91
92
const [ polly , setPolly ] = useState < PollyInput | undefined | null > ( null )
92
93
const [ submitted , setSubmitted ] = useState ( false )
94
+ const [ loadOptionsCallBack , setLoadOptionsCallBack ] = useState < Function | null > ( null )
93
95
const router = useRouter ( )
94
96
const userInfo = useContext ( UserState )
95
97
@@ -141,21 +143,22 @@ const AccessRequestFormV2 = ({
141
143
label : string
142
144
}
143
145
146
+ console . log ( searchResult )
147
+ loadOptionsCallBack ?.(
148
+ searchResult
149
+ ? searchResult . map ( ( el ) => {
150
+ return { value : el . externalID , label : el . name }
151
+ } )
152
+ : [ ]
153
+ )
154
+
144
155
const loadOptions = (
145
156
input : string ,
146
157
callback : ( options : Option [ ] ) => void
147
158
) => {
148
159
console . log ( input )
149
160
setSearchText ( input )
150
- setTimeout ( ( ) => {
151
- callback (
152
- searchResult
153
- ? searchResult . map ( ( el ) => {
154
- return { value : el . externalID , label : el . name }
155
- } )
156
- : [ ]
157
- )
158
- } , 250 )
161
+ setLoadOptionsCallBack ( ( ) => callback )
159
162
}
160
163
161
164
const onInputChange = ( newOption : Option | null ) => {
0 commit comments