import {Link, Route, Routes, useLocation, useNavigate} from 'react-router-dom'; import {useTranslation} from 'react-i18next'; import {useEffect} from 'react'; import LandingPage from './pages/LandingPage'; import LoginPage from './pages/LoginPage'; import ImprintPage from './pages/ImprintPage'; import Dashboard from "./pages/Dashboard.jsx"; import RegistrationPage from './pages/RegistrationPage.jsx'; import SettingsPage from './pages/SettingsPage.jsx'; import AdminHintsPage from './pages/AdminHintsPage.jsx'; import AdminBroadcastPage from './pages/AdminBroadcastPage.jsx'; import AdminNewsPage from './pages/AdminNewsPage.jsx'; import WhatsNewPage from './pages/WhatsNewPage.jsx'; import WelcomePage from './pages/WelcomePage.jsx'; import WelcomeGate from './components/WelcomeGate.jsx'; import AdminUsersPage from './pages/AdminUsersPage.jsx'; import GameLibrary from './pages/GameLibrary.jsx'; import GameDetail from './pages/GameDetail.jsx'; import WishlistPage from './pages/WishlistPage.jsx'; import PlayNextPage from './pages/PlayNextPage.jsx'; import StatsPage from './pages/StatsPage.jsx'; import ImportPage from './pages/ImportPage.jsx'; import PointsPage from './pages/PointsPage.jsx'; import PublicProfilePage from './pages/PublicProfilePage.jsx'; import AppHeader from './components/AppHeader.jsx'; import RequireSession from './components/RequireSession.jsx'; import {Toaster} from '@/components/ui/sonner'; import {TooltipProvider} from '@/components/ui/tooltip'; import PageBackground from './components/PageBackground.jsx'; import {usePreferences} from './context/PreferencesContext.jsx'; import {backgroundEffect} from './utils/rewards.js'; import {clearSession} from './utils/auth.js'; import useSession from './hooks/useSession.js'; import {UnsavedChangesGuard} from './hooks/useUnsavedChanges.js'; import {logout} from './utils/api.js'; function App() { const {t} = useTranslation(); const {active: isAuthenticated} = useSession(); const {appearance, equipped, syncPreferences} = usePreferences(); // Hooks for routing const navigate = useNavigate(); const location = useLocation(); // On login and on page load; the cached look shows until Auth answers. useEffect(() => { if (isAuthenticated) syncPreferences(); }, [isAuthenticated, syncPreferences]); // Waits for Auth: a late logout answer would clear the cookies of a login that came after it. const handleLogout = async () => { await logout(); clearSession(); navigate('/login'); }; return ( {/* isolate: the background layer sits behind the content but in front of this div's own background. */}
{/* A public profile shows the owner's background instead. */} {isAuthenticated && !location.pathname.startsWith('/u/') && ( )}
}/> }/> }/> }> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/> }/>
{t('IMPRINT.TITLE')}
); } export default App;