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, } from 'components'; import withAccounts from 'containers/Accounts/withAccounts'; import { inputIntent } from 'utils'; import { compose } from 'redux'; import { useAutofocus } from 'hooks'; import { useAccountDialogContext } from './AccountDialogProvider'; /** * Account form dialogs fields. */ function AccountFormDialogFields({ // #ownProps onClose, action, }) { const { values, isSubmitting } = useFormikContext(); const accountNameFieldRef = useAutofocus(); // Account form context. const { accounts, accountsTypes } = 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); }} disabled={ action === 'edit' || action === 'new_child' || action === 'NEW_ACCOUNT_DEFINED_TYPE' } 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 })} > { setFieldValue('parent_account_id', account.id); }} defaultSelectText={} selectedAccountId={value} popoverFill={true} filterByTypes={values.account_type} /> )} {({ field, meta: { error, touched } }) => ( } className={'form-group--description'} intent={inputIntent({ error, touched })} helperText={} inline={true} >