diff --git a/client/src/pages/DsiOpex.tsx b/client/src/pages/DsiOpex.tsx index 7c6d019..62f3273 100644 --- a/client/src/pages/DsiOpex.tsx +++ b/client/src/pages/DsiOpex.tsx @@ -699,8 +699,10 @@ export default function DsiOpex() { const filteredEtabs = useMemo(() => { return etablissementsRecalcules.filter(e => { - if (search && !e.nom.toLowerCase().includes(search.toLowerCase()) && - !e.code.toLowerCase().includes(search.toLowerCase())) return false; + const nom = typeof e.nom === 'string' ? e.nom : String(e.nom ?? ''); + const code = typeof e.code === 'string' ? e.code : String(e.code ?? ''); + if (search && !nom.toLowerCase().includes(search.toLowerCase()) && + !code.toLowerCase().includes(search.toLowerCase())) return false; return true; }); }, [etablissementsRecalcules, search]); @@ -708,7 +710,11 @@ export default function DsiOpex() { const sortedEtabs = useMemo(() => { const arr = [...filteredEtabs]; if (sortCol === 'total') arr.sort((a, b) => sortDir === 'asc' ? a.total - b.total : b.total - a.total); - else if (sortCol === 'nom') arr.sort((a, b) => sortDir === 'asc' ? a.nom.localeCompare(b.nom) : b.nom.localeCompare(a.nom)); + else if (sortCol === 'nom') arr.sort((a, b) => { + const na = typeof a.nom === 'string' ? a.nom : String(a.nom ?? ''); + const nb = typeof b.nom === 'string' ? b.nom : String(b.nom ?? ''); + return sortDir === 'asc' ? na.localeCompare(nb) : nb.localeCompare(na); + }); return arr; }, [filteredEtabs, sortCol, sortDir]);