// @ts-nocheck import React from 'react'; import { InputGroup, FormGroup, Position, ControlGroup, } from '@blueprintjs/core'; import { FastField, ErrorMessage } from 'formik'; import { DateInput } from '@blueprintjs/datetime'; import classNames from 'classnames'; import { CLASSES } from '@/constants/classes'; import { momentFormatter, compose, inputIntent, handleDateChange, tansformDateValue, } from '@/utils'; import { Hint, FieldHint, FieldRequiredHint, Icon, InputPrependButton, CurrencySelectList, FormattedMessage as T } from '@/components'; import { useMakeJournalFormContext } from './MakeJournalProvider'; import { JournalExchangeRateInputField } from './components'; import withSettings from '@/containers/Settings/withSettings'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import { currenciesFieldShouldUpdate, useObserveJournalNoSettings, } from './utils'; /** * Make journal entries header. */ function MakeJournalEntriesHeader({ // #ownProps onJournalNumberChanged, // #withDialog openDialog, // #withSettings journalAutoIncrement, journalNextNumber, journalNumberPrefix, }) { const { currencies } = useMakeJournalFormContext(); // Handle journal number change. const handleJournalNumberChange = () => { openDialog('journal-number-form'); }; // Handle journal number blur. const handleJournalNoBlur = (form, field) => (event) => { const newValue = event.target.value; if (field.value !== newValue && journalAutoIncrement) { openDialog('journal-number-form', { initialFormValues: { manualTransactionNo: newValue, incrementMode: 'manual-transaction', }, }); } }; useObserveJournalNoSettings(journalNumberPrefix, journalNextNumber); 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: ( ), 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); form.setFieldValue('exchange_rate', ''); }} defaultSelectText={value} /> )} {/* ----------- Exchange rate ----------- */}
); } export default compose( withDialogActions, withSettings(({ manualJournalsSettings }) => ({ journalAutoIncrement: manualJournalsSettings?.autoIncrement, journalNextNumber: manualJournalsSettings?.nextNumber, journalNumberPrefix: manualJournalsSettings?.numberPrefix, })), )(MakeJournalEntriesHeader);