import React, { useMemo, useCallback, useState } from 'react'; import { FormGroup, InputGroup, Intent, Position, MenuItem, Classes, } from '@blueprintjs/core'; import { DateInput } from '@blueprintjs/datetime'; import { FormattedMessage as T } from 'react-intl'; import moment from 'moment'; import { momentFormatter, compose, tansformDateValue } from 'utils'; import classNames from 'classnames'; import { AccountsSelectList, ListSelect, ErrorMessage, FieldRequiredHint, Icon, InputPrependButton, } from 'components'; import withCustomers from 'containers/Customers/withCustomers'; import withAccounts from 'containers/Accounts/withAccounts'; import withDialogActions from 'containers/Dialog/withDialogActions'; function ReceiptFormHeader({ formik: { errors, touched, setFieldValue, getFieldProps, values }, //#withCustomers customers, //#withAccouts accountsList, //#withDialogActions openDialog, }) { const handleDateChange = useCallback( (date) => { const formatted = moment(date).format('YYYY-MM-DD'); setFieldValue('receipt_date', formatted); }, [setFieldValue], ); const CustomerRenderer = useCallback( (cutomer, { handleClick }) => ( ), [], ); // Filter Customer const filterCustomer = (query, customer, _index, exactMatch) => { const normalizedTitle = customer.display_name.toLowerCase(); const normalizedQuery = query.toLowerCase(); if (exactMatch) { return normalizedTitle === normalizedQuery; } else { return ( `${customer.display_name} ${normalizedTitle}`.indexOf( normalizedQuery, ) >= 0 ); } }; // handle change const onChangeSelect = useCallback( (filedName) => { return (item) => { setFieldValue(filedName, item.id); }; }, [setFieldValue], ); // Filter deposit accounts. const depositAccounts = useMemo( () => accountsList.filter((a) => a?.type?.key === 'current_asset'), [accountsList], ); const handleReceiptNumberChange = useCallback(() => { openDialog('receipt-number-form', {}); }, [openDialog]); return (