import React from 'react'; import { InputGroup, FormGroup, Position, ControlGroup, } from '@blueprintjs/core'; import { FastField, ErrorMessage } from 'formik'; import { DateInput } from '@blueprintjs/datetime'; import { FormattedMessage as T } from 'react-intl'; import classNames from 'classnames'; import { CLASSES } from 'common/classes'; import { momentFormatter, tansformDateValue, saveInvoke } from 'utils'; import { Hint, FieldHint, FieldRequiredHint, Icon, InputPrependButton, CurrencySelectList, } from 'components'; import { useMakeJournalFormContext } from './MakeJournalProvider'; import withDialogActions from 'containers/Dialog/withDialogActions'; import { compose, inputIntent, handleDateChange } from 'utils'; /** * Make journal entries header. */ function MakeJournalEntriesHeader({ // #ownProps onJournalNumberChanged, // #withDialog openDialog, }) { const { currencies } = useMakeJournalFormContext(); // Handle journal number change. const handleJournalNumberChange = () => { openDialog('journal-number-form', {}); }; // Handle journal number field blur event. const handleJournalNumberChanged = (event) => { saveInvoke(onJournalNumberChanged, event.currentTarget.value); }; return (
{/*------------ Posting date -----------*/} {({ form, field: { value }, meta: { error, touched } }) => ( } labelInfo={} intent={inputIntent({ error, touched })} helperText={} minimal={true} inline={true} className={classNames(CLASSES.FILL)} > { form.setFieldValue('date', formattedDate); })} value={tansformDateValue(value)} popoverProps={{ position: Position.BOTTOM, minimal: true, }} inputProps={{ leftIcon: , }} /> )} {/*------------ Journal number -----------*/} {({ form, field, meta: { error, touched } }) => ( } labelInfo={ <> } className={'form-group--journal-number'} intent={inputIntent({ error, touched })} helperText={} fill={true} inline={true} > , }} tooltip={true} tooltipProps={{ content: 'Setting your auto-generated journal number', position: Position.BOTTOM_LEFT, }} /> )} {/*------------ Reference -----------*/} {({ form, field, meta: { error, touched } }) => ( } labelInfo={ } position={Position.RIGHT} /> } className={'form-group--reference'} intent={inputIntent({ error, touched })} helperText={} fill={true} inline={true} > )} {/*------------ Journal type -----------*/} {({ form, field, meta: { error, touched } }) => ( } className={classNames('form-group--account-type', CLASSES.FILL)} inline={true} > )} {/*------------ Currency -----------*/} {({ form, field: { value }, meta: { error, touched } }) => ( } className={classNames('form-group--currency', CLASSES.FILL)} inline={true} > { form.setFieldValue('currency_code', currencyItem.currency_code); }} defaultSelectText={value} /> )}
); } export default compose( withDialogActions, )(MakeJournalEntriesHeader);