/**
 * Admin Page - Server Component Wrapper for Next.js App Router
 *
 * Re-export this in your app/admin/[...admin]/page.js:
 * export { default } from '@zen/core/features/admin/page';
 */

import { AdminPagesLayout, AdminPagesClient } from '@zen/core/features/admin/pages';
import { protectAdmin } from '@zen/core/features/admin';
import { buildNavigationSections } from '@zen/core/features/admin/navigation';
import { collectAllDashboardData } from './dashboard/serverRegistry.js';
import { logoutAction } from '@zen/core/features/auth/actions';
import { getAppName } from '@zen/core';

export default async function AdminPage({ params }) {
  const resolvedParams = await params;
  const session = await protectAdmin();
  const appName = getAppName();

  const dashboardStats = await collectAllDashboardData();

  const navigationSections = buildNavigationSections('/');

  return (
    <AdminPagesLayout
      user={session.user}
      onLogout={logoutAction}
      appName={appName}
      navigationSections={navigationSections}
    >
      <AdminPagesClient
        params={resolvedParams}
        user={session.user}
        dashboardStats={dashboardStats}
      />
    </AdminPagesLayout>
  );
}
