Skip to content

Commit

Permalink
Fixed filter search.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Nov 28, 2024
1 parent 7262121 commit 99559c2
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/components/hooks/queries/useWebsiteValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,22 @@ export function useWebsiteValues({
const getSearch = (type: string, value: string) => {
if (value) {
const values = names[type];
return (
Object.keys(values)
.reduce((arr: string[], key: string) => {
if (values[key].toLowerCase().includes(value.toLowerCase())) {
return arr.concat(key);
}
return arr;
}, [])
.slice(0, 5)
.join(',') || value
);

if (values) {
return (
Object.keys(values)
.reduce((arr: string[], key: string) => {
if (values[key].toLowerCase().includes(value.toLowerCase())) {
return arr.concat(key);
}
return arr;
}, [])
.slice(0, 5)
.join(',') || value
);
}

return value;
}
};

Expand Down

0 comments on commit 99559c2

Please sign in to comment.