'use client'; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { useOrgAdmin } from '../_lib/org-admin-context'; export default function OrgDashboardPage() { const { orgAdmin, loading } = useOrgAdmin(); const router = useRouter(); const [data, setData] = useState(null); useEffect(() => { if (loading) return; if (!orgAdmin) { router.replace('/org/login'); return; } fetch('/api/org/dashboard') .then((r) => r.ok ? r.json() : null) .then((d) => setData(d)) .catch(() => {}); }, [orgAdmin, loading, router]); if (loading || !orgAdmin) return

Loading...

; return (

{orgAdmin.organization?.name ?? 'Organization'}

{data?.chapterCount ?? '—'} chapters

{(data?.chapters ?? []).map((chapter: any) => (
{chapter.name}

{chapter.slug}

{chapter.messageCount}

messages

{chapter.memberCount}

members

{chapter.adminCount}

admins

{chapter.isActive ? 'Active' : 'Inactive'}
))} {data && data.chapters.length === 0 && (

No chapters yet. Add a chapter.

)}
); }