@@ -32,6 +32,7 @@ import NERSuccessButton from '../../../components/NERSuccessButton';
3232import { ReimbursementRequestFormInput } from './ReimbursementRequestForm' ;
3333import { useState } from 'react' ;
3434import { useToast } from '../../../hooks/toasts.hooks' ;
35+ import NERAutocomplete from '../../../components/NERAutocomplete' ;
3536import { Link as RouterLink } from 'react-router-dom' ;
3637import { routes } from '../../../utils/routes' ;
3738import { codeAndRefundSourceName , expenseTypePipe } from '../../../utils/pipes' ;
@@ -111,6 +112,10 @@ const ReimbursementRequestFormView: React.FC<ReimbursementRequestFormViewProps>
111112 </ FormControl >
112113 ) ;
113114
115+ const expenseTypesToAutocomplete = ( expenseType : ExpenseType ) : { label : string ; id : string } => {
116+ return { label : expenseTypePipe ( expenseType ) , id : expenseType . expenseTypeId } ;
117+ } ;
118+
114119 return (
115120 < form
116121 onSubmit = { ( e ) => {
@@ -212,21 +217,21 @@ const ReimbursementRequestFormView: React.FC<ReimbursementRequestFormViewProps>
212217 < Controller
213218 name = "expenseTypeId"
214219 control = { control }
215- render = { ( { field : { onChange, value } } ) => (
216- < Select
217- onChange = { ( newValue ) => onChange ( newValue . target . value ) }
218- value = { value }
219- error = { ! ! errors . expenseTypeId }
220- >
221- { allExpenseTypes
222- . filter ( ( expenseType ) => expenseType . allowed )
223- . map ( ( expenseType ) => (
224- < MenuItem key = { expenseType . expenseTypeId } value = { expenseType . expenseTypeId } >
225- { expenseTypePipe ( expenseType ) }
226- </ MenuItem >
227- ) ) }
228- </ Select >
229- ) }
220+ render = { ( { field : { onChange, value } } ) => {
221+ const mappedExpenseTypes = allExpenseTypes . map ( expenseTypesToAutocomplete ) ;
222+ return (
223+ < NERAutocomplete
224+ id = { 'expenseType' }
225+ size = "medium"
226+ options = { mappedExpenseTypes }
227+ value = { mappedExpenseTypes . find ( ( expenseType ) => expenseType . id === value ) || null }
228+ placeholder = "Expense Type"
229+ onChange = { ( _event , newValue ) => {
230+ newValue ? onChange ( newValue . id ) : onChange ( '' ) ;
231+ } }
232+ />
233+ ) ;
234+ } }
230235 />
231236 < FormHelperText error > { errors . expenseTypeId ?. message } </ FormHelperText >
232237 </ FormControl >
0 commit comments