From c4b1b54f610cc1a2c340da767d9c931e7a62cfc7 Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 22 Apr 2026 06:48:18 +0200 Subject: [PATCH] feat: Add navigation and basic pages structure --- frontend/src/App.jsx | 35 +++++++- frontend/src/components/Navigation.jsx | 119 +++++++++++++++++++++++++ frontend/src/pages/ClubsPage.jsx | 17 ++++ frontend/src/pages/Dashboard.jsx | 47 ++-------- frontend/src/pages/ExercisesPage.jsx | 17 ++++ frontend/src/pages/ProfilePage.jsx | 60 +++++++++++++ 6 files changed, 255 insertions(+), 40 deletions(-) create mode 100644 frontend/src/components/Navigation.jsx create mode 100644 frontend/src/pages/ClubsPage.jsx create mode 100644 frontend/src/pages/ExercisesPage.jsx create mode 100644 frontend/src/pages/ProfilePage.jsx diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index aca22e7..2575da2 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,8 +1,12 @@ import React from 'react' import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom' import { AuthProvider, useAuth } from './context/AuthContext' +import Navigation from './components/Navigation' import LoginPage from './pages/LoginPage' import Dashboard from './pages/Dashboard' +import ProfilePage from './pages/ProfilePage' +import ExercisesPage from './pages/ExercisesPage' +import ClubsPage from './pages/ClubsPage' // Protected Route Component function ProtectedRoute({ children }) { @@ -22,7 +26,12 @@ function ProtectedRoute({ children }) { ) } - return isAuthenticated ? children : + return isAuthenticated ? ( + <> + + {children} + + ) : } // Public Route Component (redirect to dashboard if already logged in) @@ -68,6 +77,30 @@ function AppRoutes() { } /> + + + + } + /> + + + + } + /> + + + + } + /> {/* Catch all - redirect to dashboard or login */} } /> diff --git a/frontend/src/components/Navigation.jsx b/frontend/src/components/Navigation.jsx new file mode 100644 index 0000000..3bfa486 --- /dev/null +++ b/frontend/src/components/Navigation.jsx @@ -0,0 +1,119 @@ +import { Link, useLocation, useNavigate } from 'react-router-dom' +import { useAuth } from '../context/AuthContext' + +function Navigation() { + const location = useLocation() + const navigate = useNavigate() + const { user, logout } = useAuth() + + const handleLogout = async () => { + await logout() + navigate('/login') + } + + const isActive = (path) => location.pathname === path + + return ( + + ) +} + +export default Navigation diff --git a/frontend/src/pages/ClubsPage.jsx b/frontend/src/pages/ClubsPage.jsx new file mode 100644 index 0000000..f303db9 --- /dev/null +++ b/frontend/src/pages/ClubsPage.jsx @@ -0,0 +1,17 @@ +function ClubsPage() { + return ( +
+
+

Vereinsverwaltung

+ +
+

+ Vereinsverwaltung folgt in Kürze +

+
+
+
+ ) +} + +export default ClubsPage diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index 02cc602..7cfbff8 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react' -import { useNavigate } from 'react-router-dom' import { useAuth } from '../context/AuthContext' import api from '../utils/api' @@ -7,8 +6,7 @@ function Dashboard() { const [version, setVersion] = useState(null) const [profile, setProfile] = useState(null) const [loading, setLoading] = useState(true) - const { logout } = useAuth() - const navigate = useNavigate() + const { user } = useAuth() useEffect(() => { loadData() @@ -29,18 +27,6 @@ function Dashboard() { } } - const handleLogout = async () => { - try { - await api.logout() - } catch (err) { - console.error('Logout error:', err) - } finally { - localStorage.removeItem('authToken') - logout() - navigate('/login') - } - } - if (loading) { return (
@@ -51,32 +37,15 @@ function Dashboard() { } return ( -
- {/* Header */} -
-
-

🥋 Shinkan Jinkendo

-

- Willkommen, {profile?.name || profile?.email} -

-
- -
- - {/* Main Content */} +
+

Dashboard

+

+ Willkommen, {user?.name || user?.email}! +

{/* Welcome Card */} -
-

Dashboard

+
+

Willkommen bei Shinkan Jinkendo

Trainer- und Vereinsplattform für Kampfsport-Trainingsplanung

diff --git a/frontend/src/pages/ExercisesPage.jsx b/frontend/src/pages/ExercisesPage.jsx new file mode 100644 index 0000000..1bd768b --- /dev/null +++ b/frontend/src/pages/ExercisesPage.jsx @@ -0,0 +1,17 @@ +function ExercisesPage() { + return ( +
+
+

Übungsverwaltung

+ +
+

+ Übungsverwaltung wird als nächstes implementiert +

+
+
+
+ ) +} + +export default ExercisesPage diff --git a/frontend/src/pages/ProfilePage.jsx b/frontend/src/pages/ProfilePage.jsx new file mode 100644 index 0000000..889c341 --- /dev/null +++ b/frontend/src/pages/ProfilePage.jsx @@ -0,0 +1,60 @@ +import { useAuth } from '../context/AuthContext' + +function ProfilePage() { + const { user } = useAuth() + + return ( +
+
+

Profil

+ +
+

Persönliche Daten

+ +
+
+ Name: + {user?.name || '-'} + + E-Mail: + {user?.email} + + Rolle: + + {user?.role || 'user'} + + + Tier: + + {user?.tier || 'free'} + +
+
+
+ +
+

Einstellungen

+

+ Bearbeitung folgt in Kürze +

+
+
+
+ ) +} + +export default ProfilePage