// @ts-nocheck import React from 'react'; import { FastField, Field, ErrorMessage, useFormikContext } from 'formik'; import { Classes, FormGroup, InputGroup, TextArea, Position, ControlGroup, } from '@blueprintjs/core'; import classNames from 'classnames'; import { FormattedMessage as T, AccountsSuggestField, InputPrependText, MoneyInputGroup, FieldRequiredHint, Col, Row, If, FeatureCan, BranchSelect, BranchSelectButton, ExchangeRateMutedField, } from '@/components'; import { DateInput } from '@blueprintjs/datetime'; import { useAutofocus } from '@/hooks'; import { CLASSES, ACCOUNT_TYPE, Features } from '@/constants'; import { inputIntent, momentFormatter, tansformDateValue, handleDateChange, } from '@/utils'; import { useMoneyInDailogContext } from '../MoneyInDialogProvider'; import { useSetPrimaryBranchToForm, useForeignAccount, BranchRowDivider, } from '../utils'; import { MoneyInOutTransactionNoField } from '../../_components'; /** * Other income form fields. */ export default function OtherIncomeFormFields() { // Money in dialog context. const { accounts, account, branches } = useMoneyInDailogContext(); const { values } = useFormikContext(); const amountFieldRef = useAutofocus(); const isForeigAccount = useForeignAccount(); // Sets the primary branch to form. useSetPrimaryBranchToForm(); return ( } className={classNames('form-group--select-list', Classes.FILL)} > {/*------------ 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 -----------*/} {/*------------ 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 })} /> )} {/*------------ exchange rate -----------*/} {/*------------ other income account -----------*/} {({ form, field, meta: { error, touched } }) => ( } labelInfo={} intent={inputIntent({ error, touched })} helperText={} className={'form-group--credit_account_id'} > form.setFieldValue('credit_account_id', id) } filterByTypes={[ ACCOUNT_TYPE.INCOME, ACCOUNT_TYPE.OTHER_INCOME, ]} 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={} >