Fix event search filtering

This commit is contained in:
Codex Agent
2026-01-20 12:41:14 +01:00
parent ddd61e8165
commit 8a456d2c0d
2 changed files with 38 additions and 4 deletions

View File

@@ -204,10 +204,12 @@ function EventsList({
if (!query.trim()) return filteredByStatus;
const needle = query.toLowerCase();
return filteredByStatus.filter((event) => {
const hay = `${event.name ?? ''} ${event.location ?? ''}`.toLowerCase();
const name = resolveEventSearchName(event.name, t);
const location = resolveLocation(event, t);
const hay = `${name} ${location}`.toLowerCase();
return hay.includes(needle);
});
}, [filteredByStatus, query]);
}, [filteredByStatus, query, t]);
const filters: Array<{ key: EventStatusKey; label: string; count: number }> = [
{ key: 'all', label: t('events.list.filters.all'), count: statusCounts.all },
@@ -474,6 +476,17 @@ function renderName(name: TenantEvent['name'], t: (key: string) => string): stri
return t('events.placeholders.untitled');
}
function resolveEventSearchName(name: TenantEvent['name'], t: (key: string) => string): string {
if (typeof name === 'string') return name;
if (name && typeof name === 'object') {
const values = Object.values(name).filter((value) => typeof value === 'string');
if (values.length > 0) {
return values.join(' ');
}
}
return t('events.placeholders.untitled');
}
function resolveLocation(event: TenantEvent, t: (key: string) => string): string {
const settings = (event.settings ?? {}) as Record<string, unknown>;
const candidate =