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 { CLASSES } from 'common/classes'; import { ListSelect, ErrorMessage, FieldRequiredHint, Icon, InputPrependButton, Row, Col, } from 'components'; import withCustomers from 'containers/Customers/withCustomers'; import withDialogActions from 'containers/Dialog/withDialogActions'; function EstimateFormHeader({ formik: { errors, touched, setFieldValue, getFieldProps, values }, //#withCustomers customers, // #withDialogActions openDialog, }) { const handleDateChange = useCallback( (date_filed) => (date) => { const formatted = moment(date).format('YYYY-MM-DD'); setFieldValue(date_filed, 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 customer const onChangeCustomer = useCallback( (filedName) => { return (customer) => { setFieldValue(filedName, customer.id); }; }, [setFieldValue], ); const handleEstimateNumberChange = useCallback(() => { openDialog('estimate-number-form', {}); }, [openDialog]); return (