feat: enhance exercise management and media handling
Deploy Development / deploy (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Failing after 1m54s

- Introduced new API endpoints for managing exercise media, including upload, update, delete, and reorder functionalities.
- Updated the exercise creation and update logic to ensure goal and execution fields are validated and normalized.
- Refactored frontend components to support the new exercise media features, including a dedicated import section for complete stack files.
- Removed the deprecated ExercisesPage component and replaced it with a more modular structure for exercise management.
- Incremented database schema version to 20260427028 and updated changelog to reflect these changes.
This commit is contained in:
Lars committed 2026-04-27 14:27:25 +02:00
1 parent 2452b5e2e8
commit cb11e39201
13 files changed
+1837 -776

No files matched your search

+55 -122
View File
@@ -1,12 +1,22 @@
import React from 'react'
import { BrowserRouter as Router, Routes, Route, Navigate, NavLink, useLocation } from 'react-router-dom'
import {
BrowserRouter as Router,
Routes,
Route,
Navigate,
NavLink,
useLocation,
Outlet,
} from 'react-router-dom'
import { AuthProvider, useAuth } from './context/AuthContext'
import DesktopSidebar from './components/DesktopSidebar'
import { getMainNavItems } from './config/appNav'
import LoginPage from './pages/LoginPage'
import Dashboard from './pages/Dashboard'
import ProfilePage from './pages/ProfilePage'
import ExercisesPage from './pages/ExercisesPage'
import ExercisesListPage from './pages/ExercisesListPage'
import ExerciseDetailPage from './pages/ExerciseDetailPage'
import ExerciseFormPage from './pages/ExerciseFormPage'
import ClubsPage from './pages/ClubsPage'
import SkillsPage from './pages/SkillsPage'
import TrainingPlanningPage from './pages/TrainingPlanningPage'
@@ -35,8 +45,7 @@ function Nav({ isAdmin }) {
to={item.to}
end={!!item.end}
className={({ isActive }) =>
'nav-item' +
(navItemActive(loc.pathname, item, isActive) ? ' active' : '')
'nav-item' + (navItemActive(loc.pathname, item, isActive) ? ' active' : '')
}
>
<item.Icon size={20} strokeWidth={2} />
@@ -47,8 +56,7 @@ function Nav({ isAdmin }) {
)
}
// Protected Route Component
function ProtectedRoute({ children }) {
function ProtectedLayout() {
const { isAuthenticated, loading, user, logout } = useAuth()
const handleLogout = () => {
@@ -60,13 +68,15 @@ function ProtectedRoute({ children }) {
if (loading) {
return (
<div style={{
minHeight: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: 'var(--bg)'
}}>
<div
style={{
minHeight: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: 'var(--bg)',
}}
>
<div className="spinner"></div>
</div>
)
@@ -80,17 +90,15 @@ function ProtectedRoute({ children }) {
return (
<>
<DesktopSidebar
isAdmin={isAdmin}
user={user}
onLogout={handleLogout}
/>
<DesktopSidebar isAdmin={isAdmin} user={user} onLogout={handleLogout} />
<div className="app-shell">
<div className="app-shell__column">
<div className="app-header app-header--mobile">
<div className="app-logo">🥋 Shinkan</div>
</div>
<div className="app-main">{children}</div>
<div className="app-main">
<Outlet />
</div>
<Nav isAdmin={isAdmin} />
</div>
</div>
@@ -98,19 +106,20 @@ function ProtectedRoute({ children }) {
)
}
// 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
style={{
minHeight: '100vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: 'var(--bg)',
}}
>
<div className="spinner"></div>
</div>
)
@@ -122,7 +131,6 @@ function PublicRoute({ children }) {
function AppRoutes() {
return (
<Routes>
{/* Public Routes */}
<Route
path="/login"
element={
@@ -132,101 +140,26 @@ function AppRoutes() {
}
/>
{/* Protected Routes */}
<Route
path="/"
element={
<ProtectedRoute>
<Dashboard />
</ProtectedRoute>
}
/>
<Route
path="/profile"
element={
<ProtectedRoute>
<ProfilePage />
</ProtectedRoute>
}
/>
<Route
path="/exercises"
element={
<ProtectedRoute>
<ExercisesPage />
</ProtectedRoute>
}
/>
<Route
path="/clubs"
element={
<ProtectedRoute>
<ClubsPage />
</ProtectedRoute>
}
/>
<Route
path="/skills"
element={
<ProtectedRoute>
<SkillsPage />
</ProtectedRoute>
}
/>
<Route
path="/planning"
element={
<ProtectedRoute>
<TrainingPlanningPage />
</ProtectedRoute>
}
/>
<Route
path="/admin"
element={<Navigate to="/admin/hierarchy" replace />}
/>
<Route
path="/admin/hierarchy"
element={
<ProtectedRoute>
<AdminHierarchyPage />
</ProtectedRoute>
}
/>
<Route
path="/admin/maturity-models"
element={
<ProtectedRoute>
<AdminMaturityModelsPage />
</ProtectedRoute>
}
/>
<Route
path="/admin/catalogs"
element={
<ProtectedRoute>
<AdminCatalogsPage />
</ProtectedRoute>
}
/>
<Route
path="/admin/mediawiki-import"
element={
<ProtectedRoute>
<MediaWikiImportPage />
</ProtectedRoute>
}
/>
<Route
path="/trainer-contexts"
element={
<ProtectedRoute>
<TrainerContextsPage />
</ProtectedRoute>
}
/>
<Route element={<ProtectedLayout />}>
<Route index element={<Dashboard />} />
<Route path="profile" element={<ProfilePage />} />
<Route path="exercises">
<Route index element={<ExercisesListPage />} />
<Route path="new" element={<ExerciseFormPage />} />
<Route path=":id/edit" element={<ExerciseFormPage />} />
<Route path=":id" element={<ExerciseDetailPage />} />
</Route>
<Route path="clubs" element={<ClubsPage />} />
<Route path="skills" element={<SkillsPage />} />
<Route path="planning" element={<TrainingPlanningPage />} />
<Route path="admin" element={<Navigate to="/admin/hierarchy" replace />} />
<Route path="admin/hierarchy" element={<AdminHierarchyPage />} />
<Route path="admin/maturity-models" element={<AdminMaturityModelsPage />} />
<Route path="admin/catalogs" element={<AdminCatalogsPage />} />
<Route path="admin/mediawiki-import" element={<MediaWikiImportPage />} />
<Route path="trainer-contexts" element={<TrainerContextsPage />} />
</Route>
{/* Catch all - redirect to dashboard or login */}
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
)