Allow filter search for country and region.

This commit is contained in:
Mike Cao 2024-11-27 23:43:28 -08:00
parent 2ed7628997
commit a18d1a923c
5 changed files with 55 additions and 17 deletions

View file

@ -28,12 +28,15 @@ export function useWebsiteValues({
const getSearch = (type: string, value: string) => {
if (value) {
const values = names[type];
return Object.keys(values).reduce((code: string, key: string) => {
if (!code && values[key].toLowerCase().includes(value.toLowerCase())) {
code = key;
}
return code;
}, '');
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(',');
}
};