import { Routes, Route, Navigate } from 'react-router-dom';
import { MainLayout } from './shared/components/MainLayout';
import { ProtectedRoute } from './shared/components/ProtectedRoute';
import { LoginPage } from './features/auth/presentation/pages/LoginPage';
import { DashboardPage } from './features/dashboard/presentation/pages/DashboardPage';
import { KnowledgePage } from './features/knowledge/presentation/pages/KnowledgePage';
import { ExperiencePage } from './features/experience/presentation/pages/ExperiencePage';
import { AnalyticsPage, ReportsPage, AuditPage } from './features/analytics';
import { UsersPage } from './features/users';
import { ConversationsPage } from './features/conversations';
import { SettingsPage } from './features/settings';
import { TenantsPage } from './features/tenants';
import { McpPage } from './features/mcp';

function App() {
  return (
    <Routes>
      {/* 登录页 */}
      <Route path="/login" element={<LoginPage />} />

      {/* 需要认证的路由 */}
      <Route
        path="/"
        element={
          <ProtectedRoute>
            <MainLayout />
          </ProtectedRoute>
        }
      >
        <Route index element={<DashboardPage />} />
        <Route path="knowledge" element={<KnowledgePage />} />
        <Route path="experience" element={<ExperiencePage />} />
        <Route path="analytics" element={<AnalyticsPage />} />
        <Route path="reports" element={<ReportsPage />} />
        <Route path="audit" element={<AuditPage />} />
        <Route path="users" element={<UsersPage />} />
        <Route path="conversations" element={<ConversationsPage />} />
        <Route path="tenants" element={<TenantsPage />} />
        <Route path="mcp" element={<McpPage />} />
        <Route path="settings" element={<SettingsPage />} />
      </Route>

      {/* 未匹配路由重定向 */}
      <Route path="*" element={<Navigate to="/" replace />} />
    </Routes>
  );
}

export default App;
