// @ts-nocheck import React from 'react'; import styled from 'styled-components'; import intl from 'react-intl-universal'; import { FastField, ErrorMessage, useFormikContext } from 'formik'; import { useAutofocus } from '@/hooks'; import { isEqual } from 'lodash'; import { Classes, FormGroup, InputGroup, TextArea, Position, ControlGroup, } from '@blueprintjs/core'; import classNames from 'classnames'; import { CLASSES, Features, ACCOUNT_TYPE } from '@/constants'; import { DateInput } from '@blueprintjs/datetime'; import { Row, Col, FieldRequiredHint, FormattedMessage as T, AccountsSuggestField, InputPrependText, MoneyInputGroup, Icon, If, FeatureCan, ExchangeRateMutedField, BranchSelect, BranchSelectButton, } from '@/components'; import { inputIntent, momentFormatter, tansformDateValue, handleDateChange, compose, } from '@/utils'; import { useSetPrimaryBranchToForm } from './utils'; import { useQuickPaymentReceiveContext } from './QuickPaymentReceiveFormProvider'; import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization'; import withSettings from '@/containers/Settings/withSettings'; /** * Quick payment receive form fields. */ function QuickPaymentReceiveFormFields({ paymentReceiveAutoIncrement, // #withCurrentOrganization organization: { base_currency }, }) { const { accounts, branches, baseCurrency } = useQuickPaymentReceiveContext(); // Intl context. const { values } = useFormikContext(); const paymentReceiveFieldRef = useAutofocus(); // Sets the primary branch to form. useSetPrimaryBranchToForm(); return (
} className={classNames('form-group--select-list', Classes.FILL)} > {/* ------------- Customer name ------------- */} {({ from, field, meta: { error, touched } }) => ( } className={classNames('form-group--select-list', CLASSES.FILL)} labelInfo={} intent={inputIntent({ error, touched })} helperText={} > )} {/* ------------ Payment receive no. ------------ */} {({ form, field, meta: { error, touched } }) => ( } labelInfo={} className={('form-group--payment_receive_no', CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} > )} {/*------------ Amount Received -----------*/} {({ form: { values, setFieldValue }, field: { value }, meta: { error, touched }, }) => ( } labelInfo={} className={classNames('form-group--payment_amount', CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} > { setFieldValue('amount', amount); }} intent={inputIntent({ error, touched })} inputRef={(ref) => (paymentReceiveFieldRef.current = ref)} /> )} {/*------------ exchange rate -----------*/} {/* ------------- Payment date ------------- */} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} className={classNames('form-group--select-list', CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} > { form.setFieldValue('payment_date', formattedDate); })} popoverProps={{ position: Position.BOTTOM, minimal: true }} inputProps={{ leftIcon: , }} /> )} {/* ------------ Deposit account ------------ */} {({ form, field: { value }, meta: { error, touched } }) => ( } className={classNames( 'form-group--deposit_account_id', 'form-group--select-list', CLASSES.FILL, )} labelInfo={} intent={inputIntent({ error, touched })} helperText={} > form.setFieldValue('deposit_account_id', id) } inputProps={{ placeholder: intl.get('select_account'), }} filterByTypes={[ ACCOUNT_TYPE.CASH, ACCOUNT_TYPE.BANK, ACCOUNT_TYPE.OTHER_CURRENT_ASSET, ]} /> )} {/* ------------ Reference No. ------------ */} {({ form, field, meta: { error, touched } }) => ( } className={classNames('form-group--reference', CLASSES.FILL)} intent={inputIntent({ error, touched })} helperText={} > )} {/* --------- Statement --------- */} {({ form, field, meta: { error, touched } }) => ( } className={'form-group--statement'} >