refactoring(quick payment receive): add MoneyInput.

This commit is contained in:
elforjani3
2021-03-11 22:29:56 +02:00
parent 70f5de1674
commit 4c6e97a998

View File

@@ -14,7 +14,12 @@ import classNames from 'classnames';
import { CLASSES } from 'common/classes'; import { CLASSES } from 'common/classes';
import { DateInput } from '@blueprintjs/datetime'; import { DateInput } from '@blueprintjs/datetime';
import { FieldRequiredHint, Col, Row } from 'components'; import { FieldRequiredHint, Col, Row } from 'components';
import { AccountsSelectList, InputPrependText, Icon } from 'components'; import {
AccountsSelectList,
InputPrependText,
MoneyInputGroup,
Icon,
} from 'components';
import { import {
inputIntent, inputIntent,
momentFormatter, momentFormatter,
@@ -78,7 +83,11 @@ export default function QuickPaymentReceiveFormFields({}) {
</Row> </Row>
{/*------------ Amount Received -----------*/} {/*------------ Amount Received -----------*/}
<FastField name={'payment_amount'}> <FastField name={'payment_amount'}>
{({ form: { values }, field, meta: { error, touched } }) => ( {({
form: { values, setFieldValue },
field: { value },
meta: { error, touched },
}) => (
<FormGroup <FormGroup
label={<T id={'amount_received'} />} label={<T id={'amount_received'} />}
labelInfo={<FieldRequiredHint />} labelInfo={<FieldRequiredHint />}
@@ -89,11 +98,14 @@ export default function QuickPaymentReceiveFormFields({}) {
<ControlGroup> <ControlGroup>
<InputPrependText text={values.currency_code} /> <InputPrependText text={values.currency_code} />
<InputGroup <MoneyInputGroup
intent={inputIntent({ error, touched })} value={value}
minimal={true} minimal={true}
onChange={(amount) => {
setFieldValue('payment_amount', amount);
}}
intent={inputIntent({ error, touched })}
inputRef={(ref) => (paymentReceiveFieldRef.current = ref)} inputRef={(ref) => (paymentReceiveFieldRef.current = ref)}
{...field}
/> />
</ControlGroup> </ControlGroup>
</FormGroup> </FormGroup>