Fix event search filtering
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user