Enable search for metrics.

This commit is contained in:
Mike Cao 2024-03-05 00:45:55 -08:00
parent bbd7c4b6ea
commit b0bfd0b5ab
7 changed files with 74 additions and 30 deletions

View file

@ -68,6 +68,8 @@ export function MetricsTable({
country,
region,
city,
limit,
search,
},
{ retryDelay: delay || DEFAULT_ANIMATION_DURATION, onDataLoad },
);
@ -86,20 +88,8 @@ export function MetricsTable({
}
}
if (search) {
items = items.filter(({ x, ...data }) => {
const value = formatValue(x, type, data);
return value?.toLowerCase().includes(search.toLowerCase());
});
}
items = percentFilter(items);
if (limit) {
items = items.slice(0, limit - 1);
}
return items;
}
return [];
@ -114,6 +104,7 @@ export function MetricsTable({
className={styles.search}
value={search}
onSearch={setSearch}
delay={300}
autoFocus={true}
/>
)}