feat: List select component.

This commit is contained in:
Ahmed Bouhuolia
2020-05-24 01:48:07 +02:00
parent 80bca1d7a3
commit 18a032ffd1
6 changed files with 115 additions and 118 deletions

View File

@@ -28,6 +28,9 @@ import Icon from 'components/Icon';
import ErrorMessage from 'components/ErrorMessage';
import { fetchAccountTypes } from 'store/accounts/accounts.actions';
import {ListSelect} from 'components';
function AccountFormDialog({
name,
payload,
@@ -229,7 +232,6 @@ function AccountFormDialog({
const onChangeAccountType = useCallback(
(accountType) => {
setSelectedAccountType(accountType);
formik.setFieldValue('account_type_id', accountType.id);
},
[setSelectedAccountType, formik]
@@ -294,19 +296,20 @@ function AccountFormDialog({
errors.account_type_id && touched.account_type_id && Intent.DANGER
}
>
<Select
<ListSelect
items={accountsTypes}
noResults={<MenuItem disabled={true} text='No results.' />}
itemRenderer={accountTypeItem}
itemPredicate={filterAccountTypeItems}
popoverProps={{ minimal: true }}
onItemSelect={onChangeAccountType}
>
<Button
text={selectedAccountType ? selectedAccountType.name : <T id={'select_account_type'} />}
disabled={payload.action === 'edit'}
/>
</Select>
selectedItem={formik.values.account_type_id}
selectedItemProp={'id'}
defaultText={<T id={'select_account_type'} />}
labelProp={'name'}
buttonProps={{ disabled: payload.action === 'edit' }} />
</FormGroup>
<FormGroup

View File

@@ -27,6 +27,7 @@ import { pick } from 'lodash';
import { getDialogPayload } from 'store/dashboard/dashboard.reducer';
function CurrencyDialog({
name,
payload,