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, Icon } from 'components';
import { useBillFormContext } from './BillFormProvider';
import withDialogActions from 'containers/Dialog/withDialogActions';
import {
momentFormatter,
compose,
tansformDateValue,
handleDateChange,
inputIntent,
} from 'utils';
/**
* Fill form header.
*/
function BillFormHeader() {
// Bill form context.
const { vendors } = useBillFormContext();
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);
}}
popoverFill={true}
/>
)}
{/* ------- 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 }}
inputProps={{ leftIcon: }}
/>
)}
{/* ------- 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 }}
inputProps={{
leftIcon: ,
}}
/>
)}
{/* ------- 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(withDialogActions)(BillFormHeader);