import React from 'react'; import { FastField, ErrorMessage } from 'formik'; import { FormattedMessage as T } from 'components'; import { useAutofocus } from 'hooks'; import { Classes, FormGroup, TextArea, ControlGroup, Callout, Intent, } from '@blueprintjs/core'; import classNames from 'classnames'; import { CLASSES } from 'common/classes'; import { ACCOUNT_TYPE } from 'common/accountTypes'; import { inputIntent } from 'utils'; import { AccountsSuggestField, InputPrependText, MoneyInputGroup, FieldRequiredHint, } from 'components'; import { useBadDebtContext } from './BadDebtFormProvider'; /** * Bad debt form fields. */ function BadDebtFormFields() { const amountfieldRef = useAutofocus(); const { accounts } = useBadDebtContext(); return (

{/*------------ Written-off amount -----------*/} {({ form: { values, setFieldValue }, field: { value }, meta: { error, touched }, }) => ( } labelInfo={} className={classNames('form-group--amount', CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} > { setFieldValue('amount', amount); }} intent={inputIntent({ error, touched })} disabled={amountfieldRef} /> )} {/*------------ Expense account -----------*/} {({ form, field: { value }, meta: { error, touched } }) => ( } className={classNames( 'form-group--expense_account_id', 'form-group--select-list', CLASSES.FILL, )} labelInfo={} intent={inputIntent({ error, touched })} helperText={} > form.setFieldValue('expense_account_id', id) } filterByTypes={[ACCOUNT_TYPE.EXPENSE]} /> )} {/*------------ reason -----------*/} {({ field, meta: { error, touched } }) => ( } labelInfo={} className={'form-group--reason'} intent={inputIntent({ error, touched })} helperText={} >