import React from 'react'; import { FormGroup, InputGroup, Position, ControlGroup, } from '@blueprintjs/core'; import { DateInput } from '@blueprintjs/datetime'; import { FastField, Field, ErrorMessage } from 'formik'; import { CLASSES } from 'common/classes'; import classNames from 'classnames'; import { VendorSelectField, FieldRequiredHint, InputPrependButton, Icon, FormattedMessage as T, } from 'components'; import { vendorsFieldShouldUpdate, useObserveVendorCreditNoSettings, } from './utils'; import { useVendorCreditNoteFormContext } from './VendorCreditNoteFormProvider'; import { momentFormatter, compose, tansformDateValue, inputIntent, handleDateChange, } from 'utils'; import withSettings from 'containers/Settings/withSettings'; import withDialogActions from 'containers/Dialog/withDialogActions'; /** * Vendor Credit note form header fields. */ function VendorCreditNoteFormHeaderFields({ // #withDialogActions openDialog, // #withSettings vendorcreditAutoIncrement, vendorcreditNumberPrefix, vendorcreditNextNumber, }) { // Vendor Credit form context. const { vendors } = useVendorCreditNoteFormContext(); // Handle vendor credit number changing. const handleVendorCreditNumberChange = () => { openDialog('vendor-credit-form'); }; // Handle vendor credit no. field blur. const handleVendorCreditNoBlur = (form, field) => (event) => { const newValue = event.target.value; if (field.value !== newValue && vendorcreditAutoIncrement) { openDialog('vendor-credit-form', { initialFormValues: { manualTransactionNo: newValue, incrementMode: 'manual-transaction', }, }); } }; // Syncs vendor credit number settings with form. useObserveVendorCreditNoSettings( vendorcreditNumberPrefix, vendorcreditNextNumber, ); return (