Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ahmed Bouhuolia
2020-11-05 12:23:31 +02:00
9 changed files with 112 additions and 235 deletions

View File

@@ -14,7 +14,7 @@ import { momentFormatter, compose, tansformDateValue } from 'utils';
import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import {
ListSelect,
ContactSelecetList,
ErrorMessage,
FieldRequiredHint,
Icon,
@@ -53,21 +53,6 @@ function EstimateFormHeader({
[],
);
// 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) => {
@@ -99,17 +84,11 @@ function EstimateFormHeader({
<ErrorMessage name={'customer_id'} {...{ errors, touched }} />
}
>
<ListSelect
items={customers}
noResults={<MenuItem disabled={true} text="No results." />}
itemRenderer={CustomerRenderer}
itemPredicate={filterCustomer}
popoverProps={{ minimal: true }}
onItemSelect={onChangeCustomer('customer_id')}
selectedItem={values.customer_id}
selectedItemProp={'id'}
defaultText={<T id={'select_customer_account'} />}
labelProp={'display_name'}
<ContactSelecetList
contactsList={customers}
selectedContactId={values.customer_id}
defaultSelectText={<T id={'select_customer_account'} />}
onContactSelected={onChangeCustomer('customer_id')}
/>
</FormGroup>

View File

@@ -13,7 +13,7 @@ import { momentFormatter, compose, tansformDateValue } from 'utils';
import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import {
ListSelect,
ContactSelecetList,
ErrorMessage,
FieldRequiredHint,
Icon,
@@ -52,21 +52,6 @@ function InvoiceFormHeader({
[],
);
// 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) => {
@@ -99,17 +84,11 @@ function InvoiceFormHeader({
<ErrorMessage name={'customer_id'} {...{ errors, touched }} />
}
>
<ListSelect
items={customers}
noResults={<MenuItem disabled={true} text="No results." />}
itemRenderer={CustomerRenderer}
itemPredicate={filterCustomer}
popoverProps={{ minimal: true }}
onItemSelect={onChangeCustomer('customer_id')}
selectedItem={values.customer_id}
selectedItemProp={'id'}
defaultText={<T id={'select_customer_account'} />}
labelProp={'display_name'}
<ContactSelecetList
contactsList={customers}
selectedContactId={values.customer_id}
defaultSelectText={<T id={'select_customer_account'} />}
onContactSelected={onChangeCustomer('customer_id')}
/>
</FormGroup>

View File

@@ -16,7 +16,7 @@ import { CLASSES } from 'common/classes';
import { momentFormatter, compose, tansformDateValue } from 'utils';
import {
AccountsSelectList,
ListSelect,
ContactSelecetList,
ErrorMessage,
FieldRequiredHint,
Hint,
@@ -55,31 +55,6 @@ function PaymentReceiveFormHeader({
[setFieldValue],
);
const handleCusomterRenderer = useCallback(
(custom, { handleClick }) => (
<MenuItem
key={custom.id}
text={custom.display_name}
onClick={handleClick}
/>
),
[],
);
const handleFilterCustomer = (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
);
}
};
const onChangeSelect = useCallback(
(filedName) => {
return (item) => {
@@ -124,17 +99,11 @@ function PaymentReceiveFormHeader({
<ErrorMessage name={'customer_id'} {...{ errors, touched }} />
}
>
<ListSelect
items={customers}
noResults={<MenuItem disabled={true} text="No results." />}
itemRenderer={handleCusomterRenderer}
itemPredicate={handleFilterCustomer}
popoverProps={{ minimal: true }}
onItemSelect={onChangeSelect('customer_id')}
selectedItem={values.customer_id}
selectedItemProp={'id'}
defaultText={<T id={'select_customer_account'} />}
labelProp={'display_name'}
<ContactSelecetList
contactsList={customers}
selectedContactId={values.customer_id}
defaultSelectText={<T id={'select_customer_account'} />}
onContactSelected={onChangeSelect('customer_id')}
/>
</FormGroup>

View File

@@ -15,7 +15,7 @@ import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import {
AccountsSelectList,
ListSelect,
ContactSelecetList,
ErrorMessage,
FieldRequiredHint,
Icon,
@@ -44,32 +44,6 @@ function ReceiptFormHeader({
[setFieldValue],
);
const CustomerRenderer = useCallback(
(cutomer, { handleClick }) => (
<MenuItem
key={cutomer.id}
text={cutomer.display_name}
onClick={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) => {
@@ -108,17 +82,11 @@ function ReceiptFormHeader({
<ErrorMessage name={'customer_id'} {...{ errors, touched }} />
}
>
<ListSelect
items={customers}
noResults={<MenuItem disabled={true} text="No results." />}
itemRenderer={CustomerRenderer}
itemPredicate={filterCustomer}
popoverProps={{ minimal: true }}
onItemSelect={onChangeSelect('customer_id')}
selectedItem={values.customer_id}
selectedItemProp={'id'}
defaultText={<T id={'select_customer_account'} />}
labelProp={'display_name'}
<ContactSelecetList
contactsList={customers}
selectedContactId={values.customer_id}
defaultSelectText={<T id={'select_customer_account'} />}
onContactSelected={onChangeSelect('customer_id')}
/>
</FormGroup>