restrict employee search to first and last name fields only
This commit is contained in:
parent
505c9a46db
commit
99caaa1704
@ -46,17 +46,16 @@ const EmployeeList = () => {
|
||||
const handleSearch = (e) => {
|
||||
const value = e.target.value.toLowerCase();
|
||||
setSearchText(value);
|
||||
|
||||
|
||||
if (!employeeList.length) return;
|
||||
|
||||
const results = employeeList.filter((item) =>
|
||||
Object.values(item).some(
|
||||
(field) => field && field.toString().toLowerCase().includes(value)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const results = employeeList.filter((item) => {
|
||||
const fullName = `${item.firstName} ${item.lastName}`.toLowerCase();
|
||||
return fullName.includes(value);
|
||||
});
|
||||
|
||||
setFilteredData(results);
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentPage(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user