feat(app): search, sort and date format of the admin sheet list

This commit is contained in:
bchanot committed 2026-11-16 16:45:23 +01:00
1 parent d5852f5f8e
commit f3b58abe70
5 files changed
+121 -5

No files matched your search

+7 -4
View File
@@ -54,19 +54,22 @@ export function folded(text: string): string {
return text.normalize('NFD').replace(/\p{Diacritic}/gu, '').toLowerCase()
}
/** A sheet name contains the search, in French or in English, accents and case ignored. */
export function matchesSheetName(name: { fr: string; en: string }, query: string): boolean {
const term = folded(query.trim())
return term === '' || folded(name.fr).includes(term) || folded(name.en).includes(term)
}
/** Search by sheet name only, French or English (BDR-095), then the species chip. */
export function filterCatalog(
entries: readonly CatalogEntry[],
query: string,
speciesId: string | null,
): CatalogEntry[] {
const term = folded(query.trim())
return entries.filter(
(entry) =>
(speciesId === null || entry.species_id === speciesId) &&
(term === '' ||
folded(entry.name.fr).includes(term) ||
folded(entry.name.en).includes(term)),
matchesSheetName(entry.name, query),
)
}