// @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, ExchangeRateMutedField, BranchSelect, BranchSelectButton, FeatureCan, } from '@/components'; import { DateInput } from '@blueprintjs/datetime'; import { useAutofocus } from '@/hooks'; import { ACCOUNT_TYPE, CLASSES, Features } from '@/constants'; import { inputIntent, momentFormatter, tansformDateValue, handleDateChange, } from '@/utils'; import { useMoneyInDailogContext } from '../MoneyInDialogProvider'; import { useSetPrimaryBranchToForm, useForeignAccount, BranchRowDivider, } from '../../MoneyInDialog/utils'; import { MoneyInOutTransactionNoField } from '../../_components'; /** /** * Owner contribution form fields. */ export default function OwnerContributionFormFields() { // 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 -----------*/} {/*------------ equity account -----------*/} {({ form, field, meta: { error, touched } }) => ( } labelInfo={} intent={inputIntent({ error, touched })} helperText={} className={'form-group--credit_account_id'} > { form.setFieldValue('credit_account_id', account.id); form.setFieldValue('currency_code', account.currency_code); }} filterByTypes={ACCOUNT_TYPE.EQUITY} 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={} >