|
1 | 1 | import React, { AriaAttributes } from 'react';
|
2 | 2 | import { Account, Locale } from '../types';
|
3 | 3 | import { SearchableDropdownMultiSelect } from '@sb1/ffe-searchable-dropdown-react';
|
4 |
| -import { balanceWithCurrency, formatIncompleteAccountNumber } from '../format'; |
| 4 | +import { formatIncompleteAccountNumber } from '../format'; |
5 | 5 | import { searchMatcherIgnoringAccountNumberFormatting } from '../searchMatcherIgnoringAccountNumberFormatting';
|
6 | 6 | import { texts } from '../texts';
|
| 7 | +import { AccountMultiselectOptionBody } from './AccountMultiselectOptionBody'; |
7 | 8 |
|
8 | 9 | export interface AccountSelectorMultiProps<T extends Account = Account> {
|
9 | 10 | /**
|
@@ -98,24 +99,32 @@ export const AccountSelectorMulti = <T extends Account = Account>({
|
98 | 99 | : ['name', 'accountNumber']
|
99 | 100 | }
|
100 | 101 | postListElement={postListElement}
|
101 |
| - dropdownList={ |
102 |
| - OptionBody |
103 |
| - ? accounts |
104 |
| - : accounts.map(it => ({ |
105 |
| - ...it, |
106 |
| - balance: balanceWithCurrency( |
107 |
| - it.balance, |
108 |
| - locale, |
109 |
| - it.currencyCode, |
110 |
| - ), |
111 |
| - })) |
112 |
| - } |
| 102 | + dropdownList={accounts} |
113 | 103 | noMatch={noMatches ?? { text: texts[locale].noMatch }}
|
114 | 104 | formatter={formatter}
|
115 | 105 | onChange={onChange}
|
116 | 106 | searchAttributes={['name', 'accountNumber']}
|
117 | 107 | locale={locale}
|
118 |
| - optionBody={OptionBody} |
| 108 | + optionBody={({ item, isHighlighted, ...restOptionBody }) => { |
| 109 | + if (OptionBody) { |
| 110 | + return ( |
| 111 | + <OptionBody |
| 112 | + item={item} |
| 113 | + isHighlighted={isHighlighted} |
| 114 | + {...restOptionBody} |
| 115 | + /> |
| 116 | + ); |
| 117 | + } |
| 118 | + |
| 119 | + return ( |
| 120 | + <AccountMultiselectOptionBody |
| 121 | + item={item} |
| 122 | + isHighlighted={isHighlighted} |
| 123 | + locale={locale} |
| 124 | + showBalance={showBalance} |
| 125 | + /> |
| 126 | + ); |
| 127 | + }} |
119 | 128 | ariaInvalid={rest['aria-invalid'] ?? ariaInvalid}
|
120 | 129 | searchMatcher={searchMatcherIgnoringAccountNumberFormatting}
|
121 | 130 | selectedItems={selectedAccounts}
|
|
0 commit comments