@@ -11,6 +11,7 @@ import { SearchableDropdown } from '@sb1/ffe-searchable-dropdown-react';
11
11
import { getAccountsWithCustomAccounts } from './getAccountsWithCustomAccounts' ;
12
12
import { searchMatcherIgnoringAccountNumberFormatting } from '../searchMatcherIgnoringAccountNumberFormatting' ;
13
13
import { texts } from '../texts' ;
14
+ import { AccountActionBody } from './AccountOptionBody' ;
14
15
15
16
export interface AccountSelectorProps < T extends Account = Account > {
16
17
/**
@@ -131,14 +132,6 @@ export const AccountSelector = <T extends Account = Account>({
131
132
132
133
const _ariaInvalid = rest [ 'aria-invalid' ] ?? ariaInvalid ;
133
134
134
- const dropdownListAccounts = accounts . map ( it => ( {
135
- ...it ,
136
- accountNumber : accountFormatter ( it . accountNumber ) ,
137
- balance : OptionBody
138
- ? it . balance
139
- : balanceWithCurrency ( it . balance , locale , it . currencyCode ) ,
140
- } ) ) ;
141
-
142
135
return (
143
136
< div
144
137
className = { classNames (
@@ -165,10 +158,10 @@ export const AccountSelector = <T extends Account = Account>({
165
158
allowCustomAccount
166
159
? getAccountsWithCustomAccounts ( {
167
160
selectedAccount,
168
- accounts : dropdownListAccounts ,
161
+ accounts,
169
162
inputValue,
170
163
} )
171
- : dropdownListAccounts
164
+ : accounts
172
165
}
173
166
noMatch = {
174
167
allowCustomAccount && inputValue . trim ( ) !== ''
@@ -188,7 +181,14 @@ export const AccountSelector = <T extends Account = Account>({
188
181
onChange = { handleAccountSelected }
189
182
searchAttributes = { [ 'name' , 'accountNumber' ] }
190
183
locale = { locale }
191
- optionBody = { OptionBody }
184
+ optionBody = { ( { item, isHighlighted } ) => (
185
+ < AccountActionBody
186
+ item = { item }
187
+ isHighlighted = { isHighlighted }
188
+ locale = { locale }
189
+ showBalance = { showBalance }
190
+ />
191
+ ) }
192
192
ariaInvalid = { _ariaInvalid }
193
193
searchMatcher = { searchMatcherIgnoringAccountNumberFormatting }
194
194
selectedItem = { selectedAccount }
0 commit comments