import { Navigate, Route, Routes } from 'react-router-dom';
import { OpsLayout } from './components/OpsLayout';
import { RequireOps } from './components/RequireOps';
import { RequireAdmin } from './components/RequireAdmin';
import { AdminLayout } from './components/AdminLayout';
import { AnalyticsPage } from './pages/AnalyticsPage';
import { CreatorsPage } from './pages/CreatorsPage';
import { FeaturedPage } from './pages/FeaturedPage';
import { ReportsPage } from './pages/ReportsPage';
import { ReviewPage } from './pages/ReviewPage';
import { SummaryPage } from './pages/admin/SummaryPage';
import { UsersPage } from './pages/admin/UsersPage';
import { BillingPage } from './pages/admin/BillingPage';
import { WechatPage } from './pages/admin/WechatPage';

export function App() {
  return (
    <Routes>
      {/* Plaza ops console */}
      <Route
        element={
          <RequireOps>
            <OpsLayout />
          </RequireOps>
        }
      >
        <Route index element={<ReviewPage />} />
        <Route path="reports" element={<ReportsPage />} />
        <Route path="featured" element={<FeaturedPage />} />
        <Route path="creators" element={<CreatorsPage />} />
        <Route path="analytics" element={<AnalyticsPage />} />
      </Route>

      {/* Super-admin console */}
      <Route
        path="admin"
        element={
          <RequireAdmin>
            <AdminLayout />
          </RequireAdmin>
        }
      >
        <Route index element={<SummaryPage />} />
        <Route path="users" element={<UsersPage />} />
        <Route path="billing" element={<BillingPage />} />
        <Route path="wechat" element={<WechatPage />} />
        <Route path="*" element={<Navigate to="/admin" replace />} />
      </Route>

      <Route path="*" element={<Navigate to="/" replace />} />
    </Routes>
  );
}
