Use original search value if no results.

This commit is contained in:
Mike Cao 2024-11-27 23:47:58 -08:00
parent a18d1a923c
commit 726212120f

View File

@ -28,7 +28,8 @@ export function useWebsiteValues({
const getSearch = (type: string, value: string) => { const getSearch = (type: string, value: string) => {
if (value) { if (value) {
const values = names[type]; const values = names[type];
return Object.keys(values) return (
Object.keys(values)
.reduce((arr: string[], key: string) => { .reduce((arr: string[], key: string) => {
if (values[key].toLowerCase().includes(value.toLowerCase())) { if (values[key].toLowerCase().includes(value.toLowerCase())) {
return arr.concat(key); return arr.concat(key);
@ -36,7 +37,8 @@ export function useWebsiteValues({
return arr; return arr;
}, []) }, [])
.slice(0, 5) .slice(0, 5)
.join(','); .join(',') || value
);
} }
}; };