'use client';

import { getPage } from './registry.js';
import './pages/DashboardPage.client.js';
import './pages/UsersPage.client.js';
import './pages/RolesPage.client.js';
import './pages/ProfilePage.client.js';
import './pages/SettingsPage.client.js';
import './pages/ConfirmEmailChangePage.client.js';
import './widgets/index.client.js';
import './devkit/DevkitPage.client.js';
import '../media/pages/MediaPage.client.js';

export default function AdminPageClient({ params, user, widgetData, appConfig, devkitEnabled }) {
  const parts = params?.admin || [];
  const [first] = parts;

  const slug = first || 'dashboard';
  const page = getPage(slug) || getPage('dashboard');

  if (!page) return null;

  const { Component } = page;
  if (slug === 'dashboard') {
    return <Component user={user} stats={widgetData} />;
  }
  if (slug === 'settings') {
    return <Component user={user} appConfig={appConfig} />;
  }
  if (slug === 'devkit') {
    return <Component user={user} params={parts} devkitEnabled={devkitEnabled} />;
  }
  return <Component user={user} params={parts} />;
}
