What a mess

This commit is contained in:
Joan
2025-11-07 15:27:13 +01:00
parent 0b79b3ae59
commit 33cc9586c2
130 changed files with 29819 additions and 1175 deletions

59
pwa/src/App.tsx Normal file
View File

@@ -0,0 +1,59 @@
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'
import { AuthProvider } from './contexts/AuthContext'
import { useAuth } from './hooks/useAuth'
import Login from './components/Login'
import Game from './components/Game'
import Profile from './components/Profile'
import Leaderboards from './components/Leaderboards'
import './App.css'
function PrivateRoute({ children }: { children: React.ReactNode }) {
const { isAuthenticated, loading } = useAuth()
if (loading) {
return <div className="loading">Loading...</div>
}
return isAuthenticated ? <>{children}</> : <Navigate to="/login" />
}
function App() {
return (
<AuthProvider>
<Router>
<div className="app">
<Routes>
<Route path="/login" element={<Login />} />
<Route
path="/game"
element={
<PrivateRoute>
<Game />
</PrivateRoute>
}
/>
<Route
path="/profile/:playerId"
element={
<PrivateRoute>
<Profile />
</PrivateRoute>
}
/>
<Route
path="/leaderboards"
element={
<PrivateRoute>
<Leaderboards />
</PrivateRoute>
}
/>
<Route path="/" element={<Navigate to="/game" />} />
</Routes>
</div>
</Router>
</AuthProvider>
)
}
export default App