Backend: - Auth router (login, register, logout) - Profiles router (get current profile) - Registered in main.py Frontend: - LoginPage with login/register tabs - Dashboard with welcome screen - Simplified AuthContext for Shinkan - Protected routes in App.jsx - Public routes redirect when logged in Ready for testing! version: 0.1.0
This commit is contained in:
1 parent
fd5efa8662
commit
efc2a11a76
8 files changed
+1045
-148
No files matched your search
+76
-41
@@ -1,50 +1,85 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import React from 'react'
|
||||
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'
|
||||
import { AuthProvider } from './context/AuthContext'
|
||||
import { AuthProvider, useAuth } from './context/AuthContext'
|
||||
import LoginPage from './pages/LoginPage'
|
||||
import Dashboard from './pages/Dashboard'
|
||||
|
||||
// Protected Route Component
|
||||
function ProtectedRoute({ children }) {
|
||||
const { isAuthenticated, loading } = useAuth()
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div style={{
|
||||
minHeight: '100vh',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
background: 'var(--bg)'
|
||||
}}>
|
||||
<div className="spinner"></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return isAuthenticated ? children : <Navigate to="/login" replace />
|
||||
}
|
||||
|
||||
// Public Route Component (redirect to dashboard if already logged in)
|
||||
function PublicRoute({ children }) {
|
||||
const { isAuthenticated, loading } = useAuth()
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div style={{
|
||||
minHeight: '100vh',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
background: 'var(--bg)'
|
||||
}}>
|
||||
<div className="spinner"></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return !isAuthenticated ? children : <Navigate to="/" replace />
|
||||
}
|
||||
|
||||
function AppRoutes() {
|
||||
return (
|
||||
<Routes>
|
||||
{/* Public Routes */}
|
||||
<Route
|
||||
path="/login"
|
||||
element={
|
||||
<PublicRoute>
|
||||
<LoginPage />
|
||||
</PublicRoute>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* Protected Routes */}
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
<ProtectedRoute>
|
||||
<Dashboard />
|
||||
</ProtectedRoute>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* Catch all - redirect to dashboard or login */}
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [version, setVersion] = useState(null)
|
||||
|
||||
useEffect(() => {
|
||||
// Load version from API
|
||||
fetch('/api/version')
|
||||
.then(res => res.json())
|
||||
.then(data => setVersion(data))
|
||||
.catch(err => console.error('Failed to load version:', err))
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<AuthProvider>
|
||||
<Router>
|
||||
<div className="app">
|
||||
<div className="container">
|
||||
<h1>🥋 Shinkan Jinkendo</h1>
|
||||
<p>Trainer- und Vereinsplattform für Kampfsport-Trainingsplanung</p>
|
||||
|
||||
{version && (
|
||||
<div className="card" style={{ marginTop: '2rem' }}>
|
||||
<h3>System Status</h3>
|
||||
<p><strong>Version:</strong> {version.app_version}</p>
|
||||
<p><strong>Build:</strong> {version.build_date}</p>
|
||||
<p><strong>Environment:</strong> {version.environment}</p>
|
||||
<p><strong>DB Schema:</strong> {version.db_schema_version}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="card" style={{ marginTop: '2rem' }}>
|
||||
<h3>🚧 In Entwicklung</h3>
|
||||
<p>Die App wird gerade aufgebaut.</p>
|
||||
<ul style={{ textAlign: 'left', marginTop: '1rem' }}>
|
||||
<li>✅ Backend-Basis</li>
|
||||
<li>✅ Docker-Setup</li>
|
||||
<li>✅ Datenbank-Schema</li>
|
||||
<li>🔲 Auth-System</li>
|
||||
<li>🔲 Übungsverwaltung</li>
|
||||
<li>🔲 Trainingsplanung</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<AppRoutes />
|
||||
</Router>
|
||||
</AuthProvider>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user