import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'; import { AuthProvider, useAuth } from './contexts/AuthContext.jsx'; import { SocketProvider } from './contexts/SocketContext.jsx'; import { ToastProvider } from './contexts/ToastContext.jsx'; import Login from './pages/Login.jsx'; import Chat from './pages/Chat.jsx'; import ChangePassword from './pages/ChangePassword.jsx'; function ProtectedRoute({ children }) { const { user, loading, mustChangePassword } = useAuth(); if (loading) return (
); if (!user) return ; if (mustChangePassword) return ; return children; } function AuthRoute({ children }) { const { user, loading, mustChangePassword } = useAuth(); document.documentElement.setAttribute('data-theme', 'light'); if (loading) return null; if (user && !mustChangePassword) return ; return children; } function RestoreTheme() { const saved = localStorage.getItem('jama-theme') || 'light'; document.documentElement.setAttribute('data-theme', saved); return null; } export default function App() { return ( {/* All routes go through jama auth */} } /> } /> } /> } /> } /> ); }