MCPcopy Index your code
hub / github.com/codeaashu/DevDisplay / handleSearch

Function handleSearch

src/App.js:61–84  ·  view source on GitHub ↗
({ value, criteria })

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 1

normalizeStringFunction · 0.85

Tested by

no test coverage detected