import React from 'react'; import styled from 'styled-components'; import { FastField, ErrorMessage, useFormikContext } from 'formik'; import { FormattedMessage as T } from 'components'; import intl from 'react-intl-universal'; import { useAutofocus } from 'hooks'; import { Classes, FormGroup, InputGroup, TextArea, Position, ControlGroup, } from '@blueprintjs/core'; import classNames from 'classnames'; import { CLASSES } from 'common/classes'; import { DateInput } from '@blueprintjs/datetime'; import { FieldRequiredHint, Col, Row } from 'components'; import { AccountsSuggestField, InputPrependText, MoneyInputGroup, Icon, If, FeatureCan, ExchangeRateMutedField, BranchSelect, BranchSelectButton, } from 'components'; import { Features } from 'common'; import { ACCOUNT_TYPE } from 'common/accountTypes'; import { inputIntent, momentFormatter, tansformDateValue, handleDateChange, compose, } from 'utils'; import { useSetPrimaryBranchToForm, useForeignAccount } from './utils'; import { useQuickPaymentReceiveContext } from './QuickPaymentReceiveFormProvider'; import withSettings from 'containers/Settings/withSettings'; /** * Quick payment receive form fields. */ function QuickPaymentReceiveFormFields({ paymentReceiveAutoIncrement }) { const { accounts, branches, baseCurrency } = useQuickPaymentReceiveContext(); const isForeigAccount = useForeignAccount(); // 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('payment_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'} >