diff --git a/src/routes/contacts.index.tsx b/src/routes/contacts.index.tsx index 5794b48..456bf98 100644 --- a/src/routes/contacts.index.tsx +++ b/src/routes/contacts.index.tsx @@ -99,14 +99,13 @@ function ContactsIndex() { const archivedCount = rows.filter((r) => r.archived_at).length; const activeCount = rows.length - archivedCount; - const categoryCounts = useMemo(() => { + const typeCounts = useMemo(() => { const base = rows.filter((r) => (view === "archived" ? !!r.archived_at : !r.archived_at)); - return { - all: base.length, - companies: base.filter((r) => categoryOf(r.contact_type) === "companies").length, - people: base.filter((r) => categoryOf(r.contact_type) === "people").length, - lawyers: base.filter((r) => categoryOf(r.contact_type) === "lawyers").length, - }; + const counts: Record = { all: base.length }; + for (const t of CONTACT_TYPES) { + counts[t.value] = base.filter((r) => (r.contact_type ?? "other") === t.value).length; + } + return counts; }, [rows, view]); const remove = async (id: string, name: string) => {