import React from 'react';
import { FastField, ErrorMessage } from 'formik';
import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import {
Classes,
FormGroup,
InputGroup,
TextArea,
Position,
ControlGroup,
} from '@blueprintjs/core';
import { useAutofocus } from 'hooks';
import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import { DateInput } from '@blueprintjs/datetime';
import { FieldRequiredHint, Col, Row } from 'components';
import { ACCOUNT_TYPE } from 'common/accountTypes';
import {
AccountsSuggestField,
InputPrependText,
MoneyInputGroup,
Icon,
} from 'components';
import {
inputIntent,
momentFormatter,
tansformDateValue,
handleDateChange,
} from 'utils';
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
/**
* Quick payment made form fields.
*/
export default function QuickPaymentMadeFormFields() {
const { accounts } = useQuickPaymentMadeContext();
// Intl context.
const paymentMadeFieldRef = useAutofocus();
return (
{/* ------------- Vendor name ------------- */}
{({ from, field, meta: { error, touched } }) => (
}
className={classNames('form-group--select-list', CLASSES.FILL)}
labelInfo={}
intent={inputIntent({ error, touched })}
helperText={}
>
)}
{/* ------------ Payment number. ------------ */}
{({ form, field, meta: { error, touched } }) => (
}
className={('form-group--payment_number', 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) => (paymentMadeFieldRef.current = ref)}
/>
)}
{/* ------------- 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: ,
}}
/>
)}
{/* ------------ payment account ------------ */}
{({ form, field: { value }, meta: { error, touched } }) => (
}
className={classNames(
'form-group--payment_account_id',
'form-group--select-list',
CLASSES.FILL,
)}
labelInfo={}
intent={inputIntent({ error, touched })}
helperText={}
>
form.setFieldValue('payment_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'}
>
)}
);
}