restrict employee search to first and last name fields only #81

Merged
vikas.nale merged 1 commits from pramod_Bug#150 into Issue_May_2W 2025-05-08 10:15:07 +00:00
Collaborator

Employee List -> search

Issue

const results = employeeList.filter((item) =>
  Object.values(item).some(
    (field) => field && field.toString().toLowerCase().includes(value)
  )
);

this logic searched across all fields of the employeeList object, not just firstName and lastName.
It could return false positives if the value matched unrelated fields like id, email, designation, etc.
It also made the filtering unpredictable and possibly inaccurate for name-specific searches.

Fixed

const results = employeeList.filter((item) => {
  const fullName = `${item.firstName} ${item.lastName}`.toLowerCase();
  return fullName.includes(value);
});

now it, Strictly filtered on full name.
Accurate, case-insensitive, and user-friendly.
Prevents irrelevant data from appearing in the results.

_Employee List -> search_ **Issue** ``` const results = employeeList.filter((item) => Object.values(item).some( (field) => field && field.toString().toLowerCase().includes(value) ) ); ``` this logic searched across all fields of the employeeList object, not just firstName and lastName. It could return false positives if the value matched unrelated fields like id, email, designation, etc. It also made the filtering unpredictable and possibly inaccurate for name-specific searches. **Fixed** ``` const results = employeeList.filter((item) => { const fullName = `${item.firstName} ${item.lastName}`.toLowerCase(); return fullName.includes(value); }); ``` now it, Strictly filtered on full name. Accurate, case-insensitive, and user-friendly. Prevents irrelevant data from appearing in the results.
pramod.mahajan added 1 commit 2025-05-08 06:34:23 +00:00
vikas.nale merged commit e856220173 into Issue_May_2W 2025-05-08 10:15:07 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/marco.pms.web#81
No description provided.