import { HashRouter as Router, Routes, Route, Link, Navigate, useLocation } from 'react-router-dom'; import { Activity, Users, Settings, Shield, MoreVertical, RefreshCw, BookOpen, Wrench, History, Globe, LogOut, Route as RouteIcon } from 'lucide-react'; import { useState, useEffect } from 'react'; import type { ReactNode } from 'react'; // Components import Dashboard from './pages/Dashboard'; import Clients from './pages/Clients'; import SettingsPage from './pages/Settings'; import Wiki from './pages/Wiki'; import Tools from './pages/Tools'; import AuditLogs from './pages/AuditLogs'; import Login from './pages/Login'; import Routing from './pages/Routing'; // State and Context import { api } from './lib/api'; import { LanguageProvider, useLanguage } from './lib/LanguageContext'; function AuthGuard({ children }: { children: ReactNode }) { const [isAuthenticated, setIsAuthenticated] = useState(null); const location = useLocation(); useEffect(() => { const checkAuth = async () => { try { await api.getServerStatus(); setIsAuthenticated(true); } catch { setIsAuthenticated(false); } }; checkAuth(); }, [location.pathname]); if (isAuthenticated === null) { return (
); } if (!isAuthenticated) { return ; } return <>{children}; } function MainLayout() { const { t, language, setLanguage } = useLanguage(); const [isSidebarOpen, setSidebarOpen] = useState(true); return (
{/* Sidebar */} {/* Main Content */}
{/* Header */}
{/* Language Switcher */}
{t('header_core_online')}
{/* Page Content */}
{/* Background decorative blobs */}
} /> } /> } /> } /> } /> } /> } />
); } function AppContent() { return ( window.location.href = '#/'} />} /> } /> ); } export default function App() { return ( ); }