feat(account): add currency select.

This commit is contained in:
elforjani13
2022-02-27 14:10:22 +02:00
parent deddbea752
commit a3c79d98b0
4 changed files with 38 additions and 7 deletions

View File

@@ -17,12 +17,14 @@ import {
Hint,
AccountsSelectList,
AccountsTypesSelect,
CurrencySelect,
} from 'components';
import withAccounts from 'containers/Accounts/withAccounts';
import { inputIntent } from 'utils';
import { compose } from 'redux';
import { useAutofocus } from 'hooks';
import { FOREIGN_CURRENCY_ACCOUNTS } from '../../../common/accountTypes';
import { useAccountDialogContext } from './AccountDialogProvider';
/**
@@ -37,7 +39,7 @@ function AccountFormDialogFields({
const accountNameFieldRef = useAutofocus();
// Account form context.
const { accounts, accountsTypes } = useAccountDialogContext();
const { accounts, accountsTypes, currencies } = useAccountDialogContext();
return (
<Form>
@@ -58,6 +60,7 @@ function AccountFormDialogFields({
defaultSelectText={<T id={'select_account_type'} />}
onTypeSelected={(accountType) => {
form.setFieldValue('account_type', accountType.key);
form.setFieldValue('currency_code', '');
}}
disabled={
action === 'edit' ||
@@ -159,6 +162,24 @@ function AccountFormDialogFields({
</FastField>
</If>
<If condition={FOREIGN_CURRENCY_ACCOUNTS.includes(values.account_type)}>
{/*------------ Currency -----------*/}
<FastField name={'currency_code'}>
{({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup
label={<T id={'currency'} />}
className={classNames('form-group--select-list', Classes.FILL)}
inline={true}
>
<CurrencySelect
name={'currency_code'}
currencies={currencies}
popoverProps={{ minimal: true }}
/>
</FormGroup>
)}
</FastField>
</If>
<FastField name={'description'}>
{({ field, meta: { error, touched } }) => (
<FormGroup