🐛 Better implementation
This commit is contained in:
parent
f5729af068
commit
2416bba52a
@ -60,16 +60,10 @@ export default class SearchBar extends React.Component<IProps, IState> {
|
|||||||
const value = event.target.value.toLowerCase();
|
const value = event.target.value.toLowerCase();
|
||||||
|
|
||||||
if (folder.office_folder_has_customers) {
|
if (folder.office_folder_has_customers) {
|
||||||
const customersNames = folder.office_folder_has_customers?.reduce((acc: string[], customer) => {
|
const customerNames = folder.office_folder_has_customers.map((customer) => {
|
||||||
return acc.concat(
|
return `${customer.customer.contact.first_name.toLowerCase()} ${customer.customer.contact.last_name.toLowerCase()}`;
|
||||||
`${customer.customer.contact.first_name.toLowerCase()} ${customer.customer.contact.last_name.toLowerCase()}`,
|
}).join(", ");
|
||||||
);
|
return name.includes(value) || number.includes(value) || customerNames.includes(value);
|
||||||
}, []);
|
|
||||||
let namesIncludesValue = false;
|
|
||||||
customersNames.forEach((name) => {
|
|
||||||
if (name.includes(value)) namesIncludesValue = true;
|
|
||||||
});
|
|
||||||
return name.includes(value) || number.includes(value) || namesIncludesValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name.includes(value) || number.includes(value);
|
return name.includes(value) || number.includes(value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user