import React from 'react'; import { Form, FastField, Field, ErrorMessage, useFormikContext } from 'formik'; import classNames from 'classnames'; import { FormattedMessage as T } from 'components'; import { Button, Classes, FormGroup, InputGroup, Intent, TextArea, Checkbox, } from '@blueprintjs/core'; import { If, FieldRequiredHint, 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'; /** * Account form dialogs fields. */ function AccountFormDialogFields({ // #ownProps onClose, action, }) { const { values, isSubmitting } = useFormikContext(); const accountNameFieldRef = useAutofocus(); // Account form context. const { fieldsDisabled, accounts, accountsTypes, currencies } = useAccountDialogContext(); return (
{({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} className={classNames('form-group--account-type', Classes.FILL)} inline={true} helperText={} intent={inputIntent({ error, touched })} > } onTypeSelected={(accountType) => { form.setFieldValue('account_type', accountType.key); form.setFieldValue('currency_code', ''); }} disabled={fieldsDisabled.accountType} popoverProps={{ minimal: true }} popoverFill={true} /> )} {({ field, meta: { error, touched } }) => ( } labelInfo={} className={'form-group--account-name'} intent={inputIntent({ error, touched })} helperText={} inline={true} > (accountNameFieldRef.current = ref)} {...field} /> )} {({ form, field, meta: { error, touched } }) => ( } className={'form-group--account-code'} intent={inputIntent({ error, touched })} helperText={} inline={true} labelInfo={} />} > )} {({ field, meta: { error, touched } }) => ( } name={'subaccount'} {...field} /> )} {({ form: { values, setFieldValue }, field: { value }, meta: { error, touched }, }) => ( } className={classNames( 'form-group--parent-account', Classes.FILL, )} inline={true} intent={inputIntent({ error, touched })} helperText={} > { setFieldValue('parent_account_id', account.id); }} defaultSelectText={} selectedAccountId={value} popoverFill={true} filterByTypes={values.account_type} /> )} {/*------------ Currency -----------*/} {({ form, field: { value }, meta: { error, touched } }) => ( } className={classNames('form-group--select-list', Classes.FILL)} inline={true} > )} {({ field, meta: { error, touched } }) => ( } className={'form-group--description'} intent={inputIntent({ error, touched })} helperText={} inline={true} >