({ value, criteria })
| 59 | }; |
| 60 | |
| 61 | const handleSearch = ({ value, criteria }) => { |
| 62 | const normalizeString = (str) => |
| 63 | str |
| 64 | .toLowerCase() |
| 65 | .replace(/\s*,\s*/g, ' ') |
| 66 | .replace(/\s+/g, ' ') |
| 67 | .trim(); |
| 68 | |
| 69 | const normalizedValue = normalizeString(value); |
| 70 | |
| 71 | const filteredResults = combinedData.filter((user) => { |
| 72 | if (criteria === 'name') { |
| 73 | return normalizeString(user.name).includes(normalizedValue); |
| 74 | } else if (criteria === 'location') { |
| 75 | return normalizeString(user.location).includes(normalizedValue); |
| 76 | } else if (criteria === 'skill') { |
| 77 | return user.skills.some((skill) => normalizeString(skill).includes(normalizedValue)); |
| 78 | } |
| 79 | return false; |
| 80 | }); |
| 81 | |
| 82 | setProfiles(filteredResults); |
| 83 | setSearching(true); |
| 84 | }; |
| 85 | |
| 86 | const handleNextPage = () => { |
| 87 | const totalPages = Math.ceil((searching ? profiles.length : combinedData.length) / recordsPerPage); |
nothing calls this directly
no test coverage detected