import React from 'react'; import { FastField, ErrorMessage } from 'formik'; import { Classes, FormGroup, InputGroup, TextArea, Position, ControlGroup, } from '@blueprintjs/core'; import classNames from 'classnames'; import { FormattedMessage as T, AccountsSuggestField, InputPrependText, MoneyInputGroup, } from 'components'; import { DateInput } from '@blueprintjs/datetime'; import { useAutofocus } from 'hooks'; import { FieldRequiredHint, Col, Row } from 'components'; import { inputIntent, momentFormatter, tansformDateValue, handleDateChange, } from 'utils'; import { CLASSES } from 'common/classes'; import { useMoneyInDailogContext } from '../MoneyInDialogProvider'; /** * Other income form fiedls. */ function OtherIncomeFormFields() { // Money in dialog context. const { accounts } = useMoneyInDailogContext(); const amountFieldRef = useAutofocus(); return (
{/*------------ Date -----------*/} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} intent={inputIntent({ error, touched })} helperText={} minimal={true} className={classNames(CLASSES.FILL, 'form-group--date')} > { form.setFieldValue('date', formattedDate); })} value={tansformDateValue(value)} popoverProps={{ position: Position.BOTTOM, minimal: true, }} intent={inputIntent({ error, touched })} /> )} {/*------------ Transaction number -----------*/} {({ form, field, meta: { error, touched } }) => ( } intent={inputIntent({ error, touched })} helperText={} className={'form-group--transaction_number'} > )} {/*------------ amount -----------*/} {({ form: { values, setFieldValue }, field: { value }, meta: { error, touched }, }) => ( } labelInfo={} intent={inputIntent({ error, touched })} helperText={} className={'form-group--amount'} > { setFieldValue('amount', amount); }} inputRef={(ref) => (amountFieldRef.current = ref)} intent={inputIntent({ error, touched })} /> )} {/*------------ other income account -----------*/} {({ form, field, meta: { error, touched } }) => ( } labelInfo={} intent={inputIntent({ error, touched })} helperText={} className={'form-group--cashflow_account_id'} > form.setFieldValue('cashflow_account_id', id) } inputProps={{ intent: inputIntent({ error, touched }), }} /> )} {/*------------ Reference -----------*/} {({ form, field, meta: { error, touched } }) => ( } intent={inputIntent({ error, touched })} helperText={} className={'form-group--reference-no'} > )} {/*------------ description -----------*/} {({ field, meta: { error, touched } }) => ( } className={'form-group--description'} intent={inputIntent({ error, touched })} helperText={} >