Merge pull request 'restrict employee search to first and last name fields only' (#81) from pramod_Bug#150 into Issue_May_2W
Reviewed-on: #81
This commit is contained in:
commit
e856220173
@ -46,17 +46,16 @@ const EmployeeList = () => {
|
|||||||
const handleSearch = (e) => {
|
const handleSearch = (e) => {
|
||||||
const value = e.target.value.toLowerCase();
|
const value = e.target.value.toLowerCase();
|
||||||
setSearchText(value);
|
setSearchText(value);
|
||||||
|
|
||||||
if (!employeeList.length) return;
|
if (!employeeList.length) return;
|
||||||
|
|
||||||
const results = employeeList.filter((item) =>
|
const results = employeeList.filter((item) => {
|
||||||
Object.values(item).some(
|
const fullName = `${item.firstName} ${item.lastName}`.toLowerCase();
|
||||||
(field) => field && field.toString().toLowerCase().includes(value)
|
return fullName.includes(value);
|
||||||
)
|
});
|
||||||
);
|
|
||||||
|
|
||||||
setFilteredData(results);
|
setFilteredData(results);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentPage(1);
|
setCurrentPage(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user