import React from 'react';
import { FormGroup, InputGroup, Position } from '@blueprintjs/core';
import { DateInput } from '@blueprintjs/datetime';
import { FormattedMessage as T } from 'react-intl';
import { FastField, ErrorMessage } from 'formik';
import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import { ContactSelecetList, FieldRequiredHint, Row, Col } from 'components';
import withVendors from 'containers/Vendors/withVendors';
import withAccounts from 'containers/Accounts/withAccounts';
import withDialogActions from 'containers/Dialog/withDialogActions';
import {
momentFormatter,
compose,
tansformDateValue,
handleDateChange,
inputIntent,
saveInvoke,
} from 'utils';
/**
* Fill form header.
*/
function BillFormHeader({
onBillNumberChanged,
//#withVendors
vendorItems,
}) {
const handleBillNumberBlur = (event) => {
saveInvoke(onBillNumberChanged, event.currentTarget.value);
};
return (
{/* ------- Vendor name ------ */}
{({ form, field: { value }, meta: { error, touched } }) => (
}
inline={true}
className={classNames(CLASSES.FILL, 'form-group--vendor')}
labelInfo={}
intent={inputIntent({ error, touched })}
helperText={}
>
}
onContactSelected={(contact) => {
form.setFieldValue('vendor_id', contact.id);
}}
/>
)}
{/* ------- Bill date ------- */}
{({ form, field: { value }, meta: { error, touched } }) => (
}
inline={true}
labelInfo={}
className={classNames(CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={}
>
{
form.setFieldValue('bill_date', formattedDate);
})}
popoverProps={{ position: Position.BOTTOM, minimal: true }}
/>
)}
{/* ------- Due date ------- */}
{({ form, field: { value }, meta: { error, touched } }) => (
}
inline={true}
className={classNames(
'form-group--due-date',
'form-group--select-list',
CLASSES.FILL,
)}
intent={inputIntent({ error, touched })}
helperText={}
>
{
form.setFieldValue('due_date', formattedDate);
})}
popoverProps={{ position: Position.BOTTOM, minimal: true }}
/>
)}
{/* ------- Bill number ------- */}
{({ field, meta: { error, touched } }) => (
}
inline={true}
className={('form-group--bill_number', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={}
>
)}
{/* ------- Reference ------- */}
{({ field, meta: { error, touched } }) => (
}
inline={true}
className={classNames('form-group--reference', CLASSES.FILL)}
intent={inputIntent({ error, touched })}
helperText={}
>
)}
);
}
export default compose(
withVendors(({ vendorItems }) => ({
vendorItems,
})),
withAccounts(({ accountsList }) => ({
accountsList,
})),
withDialogActions,
)(BillFormHeader);