Refactor navigation components and enhance return context handling
Deploy Development / deploy (push) Failing after 24s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Failing after 7s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m22s
Deploy Development / deploy (push) Failing after 24s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Failing after 7s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m22s
- Replaced `PageReturnLink` with `PageReturnButton` for consistent back navigation across various pages. - Updated multiple components, including `ExercisePeekModal`, `PageFormEditorChrome`, and `ExerciseDetailPage`, to utilize the new return context features. - Enhanced CSS styles for the new return button to improve visual consistency. - Improved navigation logic in `TrainingFrameworkProgramEditPage` and `TrainingModuleEditPage` to ensure seamless user experience when navigating back to previous locations.
This commit is contained in:
1 parent
6e6270b717
commit
4588ef4c7e
28 files changed
+497
-190
No files matched your search
@@ -1,9 +1,14 @@
|
||||
import React, { useState, useEffect, useMemo } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { CalendarCheck, ClipboardList, FilePenLine, Library } from 'lucide-react'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import api from '../utils/api'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import {
|
||||
buildDashboardReturnContext,
|
||||
buildTrainingRunReturnContext,
|
||||
} from '../utils/navReturnContext'
|
||||
import EmailVerificationBanner from '../components/EmailVerificationBanner'
|
||||
import DashboardTrainingVisibilityWidget from '../components/DashboardTrainingVisibilityWidget'
|
||||
import DashboardOrgInboxWidget from '../components/DashboardOrgInboxWidget'
|
||||
@@ -26,6 +31,7 @@ function Dashboard() {
|
||||
const [dashboardKpisErr, setDashboardKpisErr] = useState(null)
|
||||
const { user, loading: authLoading } = useAuth()
|
||||
const tenantClubDepKey = useMemo(() => getTenantClubDependencyKey(user), [user])
|
||||
const dashboardReturn = useMemo(() => buildDashboardReturnContext(), [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!user?.id) {
|
||||
@@ -166,14 +172,20 @@ function Dashboard() {
|
||||
<ul className="dashboard-preview-card__list">
|
||||
{phase0Stats.draftPreview.map((ex) => (
|
||||
<li key={ex.id}>
|
||||
<Link to={`/exercises/${ex.id}/edit`} className="dashboard-preview-card__link">
|
||||
<NavStateLink
|
||||
to={`/exercises/${ex.id}/edit`}
|
||||
returnContext={dashboardReturn}
|
||||
className="dashboard-preview-card__link"
|
||||
>
|
||||
{ex.title}
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p style={{ margin: '0.75rem 0 0', fontSize: '0.86rem' }}>
|
||||
<Link to={draftsHref}>Alle Entwürfe in der Übersicht</Link>
|
||||
<NavStateLink to={draftsHref} returnContext={dashboardReturn}>
|
||||
Alle Entwürfe in der Übersicht
|
||||
</NavStateLink>
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
@@ -205,9 +217,13 @@ function Dashboard() {
|
||||
<ul className="dashboard-preview-card__list">
|
||||
{trainingHome.upcoming.map((u) => (
|
||||
<li key={u.id}>
|
||||
<Link to={`/planning/run/${u.id}`} className="dashboard-preview-card__link">
|
||||
<NavStateLink
|
||||
to={`/planning/run/${u.id}`}
|
||||
returnContext={buildTrainingRunReturnContext(u.id) || dashboardReturn}
|
||||
className="dashboard-preview-card__link"
|
||||
>
|
||||
{unitWhenLabel(u)}
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
{u.group_name ? (
|
||||
<span className="dashboard-preview-card__meta">{` — ${u.group_name}`}</span>
|
||||
) : null}
|
||||
@@ -237,9 +253,13 @@ function Dashboard() {
|
||||
const snippet = (u.trainer_notes || u.notes || '').trim().slice(0, 120)
|
||||
return (
|
||||
<li key={`n-${u.id}`}>
|
||||
<Link to={`/planning/run/${u.id}`} className="dashboard-preview-card__link">
|
||||
<NavStateLink
|
||||
to={`/planning/run/${u.id}`}
|
||||
returnContext={buildTrainingRunReturnContext(u.id) || dashboardReturn}
|
||||
className="dashboard-preview-card__link"
|
||||
>
|
||||
{unitWhenLabel(u)}
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
{u.group_name ? (
|
||||
<span className="dashboard-preview-card__meta">{` · ${u.group_name}`}</span>
|
||||
) : null}
|
||||
@@ -266,9 +286,13 @@ function Dashboard() {
|
||||
<ul className="dashboard-preview-card__list">
|
||||
{trainingHome.reviewPending.map((u) => (
|
||||
<li key={`r-${u.id}`}>
|
||||
<Link to={`/planning/units/${u.id}/edit`} className="dashboard-preview-card__link">
|
||||
<NavStateLink
|
||||
to={`/planning/units/${u.id}/edit`}
|
||||
returnContext={dashboardReturn}
|
||||
className="dashboard-preview-card__link"
|
||||
>
|
||||
{(u.actual_date || u.planned_date || '').toString().slice(0, 10) || 'Datum'}
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
{u.group_name ? (
|
||||
<span className="dashboard-preview-card__meta">{` — ${u.group_name}`}</span>
|
||||
) : null}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Link, useNavigate, useParams, useLocation } from 'react-router-dom'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import { useParams, useLocation } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import {
|
||||
EXERCISES_LIST_PATH,
|
||||
buildCurrentLocationReturnContext,
|
||||
} from '../utils/navReturnContext'
|
||||
import ExerciseRichTextBlock from '../components/ExerciseRichTextBlock'
|
||||
import ExerciseAttachmentMediaStrip from '../components/ExerciseAttachmentMediaStrip'
|
||||
import CombinationPlanBracket from '../components/CombinationPlanBracket'
|
||||
@@ -54,8 +60,11 @@ function metaParts(exercise) {
|
||||
|
||||
function ExerciseDetailPage() {
|
||||
const { id } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const editReturnContext = useMemo(
|
||||
() => buildCurrentLocationReturnContext(location, 'Zurück zur Übung'),
|
||||
[location]
|
||||
)
|
||||
const [exercise, setExercise] = useState(null)
|
||||
const [error, setError] = useState(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
@@ -98,9 +107,10 @@ function ExerciseDetailPage() {
|
||||
<div className="card">
|
||||
<h2>Übung</h2>
|
||||
<p style={{ color: 'var(--danger)' }}>{msg}</p>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate('/exercises')}>
|
||||
Zur Übersicht
|
||||
</button>
|
||||
<PageReturnButton
|
||||
fallbackPath={EXERCISES_LIST_PATH}
|
||||
fallbackLabel="Zurück zur Übungsliste"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -109,7 +119,6 @@ function ExerciseDetailPage() {
|
||||
if (!exercise) return null
|
||||
|
||||
const meta = metaParts(exercise)
|
||||
const fromExerciseEdit = location.state?.fromExerciseEdit === true
|
||||
|
||||
const isCombinationDetail =
|
||||
(exercise.exercise_kind || '').toLowerCase().trim() === 'combination' &&
|
||||
@@ -131,13 +140,19 @@ function ExerciseDetailPage() {
|
||||
onClose={() => setEmbeddedPeekExerciseId(null)}
|
||||
/>
|
||||
<div style={{ marginBottom: '12px', display: 'flex', justifyContent: 'space-between', gap: '8px', flexWrap: 'wrap', alignItems: 'center' }}>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate('/exercises')}>
|
||||
← Übersicht
|
||||
</button>
|
||||
<PageReturnButton
|
||||
fallbackPath={EXERCISES_LIST_PATH}
|
||||
fallbackLabel="Zurück zur Übungsliste"
|
||||
className="page-return-btn btn btn-secondary btn-small"
|
||||
/>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px', marginLeft: 'auto' }}>
|
||||
<Link to={`/exercises/${exercise.id}/edit`} className="btn btn-primary">
|
||||
{fromExerciseEdit ? 'Zurück zur Bearbeitung' : 'Bearbeiten'}
|
||||
</Link>
|
||||
<NavStateLink
|
||||
to={`/exercises/${exercise.id}/edit`}
|
||||
returnContext={editReturnContext}
|
||||
className="btn btn-primary"
|
||||
>
|
||||
Bearbeiten
|
||||
</NavStateLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { useEffect, useState, useCallback, useRef, useMemo } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import { buildMediaLibraryReturnContext } from '../utils/navReturnContext'
|
||||
import {
|
||||
LayoutGrid,
|
||||
List,
|
||||
@@ -108,21 +110,23 @@ function parseTagsInput(s) {
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function MediaUsageBlock({ usage, compact }) {
|
||||
function MediaUsageBlock({ usage, compact, returnContext }) {
|
||||
const u = usage || { exercises: [], training_units: [] }
|
||||
const ex = u.exercises || []
|
||||
const tus = u.training_units || []
|
||||
if (!ex.length && !tus.length)
|
||||
return <span className="media-library__hint">{compact ? '—' : 'Noch in keiner Übung / Einheit verknüpft.'}</span>
|
||||
const LinkOrNav = returnContext ? NavStateLink : Link
|
||||
const linkExtra = returnContext ? { returnContext } : {}
|
||||
return (
|
||||
<div className="media-library__usage-links">
|
||||
{ex.length ? (
|
||||
<div>
|
||||
<strong>Übungen</strong>{' '}
|
||||
{ex.map((e) => (
|
||||
<Link key={e.id} to={`/exercises/${e.id}`} title={e.title}>
|
||||
<LinkOrNav key={e.id} to={`/exercises/${e.id}`} title={e.title} {...linkExtra}>
|
||||
{e.title.length > (compact ? 18 : 40) ? `${e.title.slice(0, compact ? 18 : 40)}…` : e.title}
|
||||
</Link>
|
||||
</LinkOrNav>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
@@ -134,9 +138,9 @@ function MediaUsageBlock({ usage, compact }) {
|
||||
[t.planned_date, (t.group_name || '').trim()].filter(Boolean).join(' · ') || `Einheit #${t.id}`
|
||||
const short = label.length > (compact ? 20 : 36) ? `${label.slice(0, compact ? 20 : 36)}…` : label
|
||||
return (
|
||||
<Link key={t.id} to={`/planning/units/${t.id}/edit`} title={label}>
|
||||
<LinkOrNav key={t.id} to={`/planning/units/${t.id}/edit`} title={label} {...linkExtra}>
|
||||
{short}
|
||||
</Link>
|
||||
</LinkOrNav>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
@@ -297,6 +301,7 @@ export default function MediaLibraryPage() {
|
||||
const isSuperadmin = user?.role === 'superadmin'
|
||||
const hasClubOrgAdmin = activeClubMemberships(user?.clubs).some((c) => (c.roles || []).includes('club_admin'))
|
||||
const tenantClubDepKey = useMemo(() => getTenantClubDependencyKey(user), [user])
|
||||
const mediaLibraryReturn = useMemo(() => buildMediaLibraryReturnContext(), [])
|
||||
|
||||
const archiveVisOptions = useMemo(
|
||||
() => VIS_OPTIONS.filter((o) => o.value !== 'official' || isSuperadmin),
|
||||
@@ -1004,7 +1009,7 @@ export default function MediaLibraryPage() {
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<MediaUsageBlock usage={it.usage} compact />
|
||||
<MediaUsageBlock usage={it.usage} compact returnContext={mediaLibraryReturn} />
|
||||
{(it.lifecycle_state || 'active') === 'active' && !it.legal_hold_active && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -1074,7 +1079,7 @@ export default function MediaLibraryPage() {
|
||||
{(it.tags || []).length ? (it.tags || []).join(', ') : '—'}
|
||||
</td>
|
||||
<td className="media-library__td-usage media-library__td-sub">
|
||||
<MediaUsageBlock usage={it.usage} compact />
|
||||
<MediaUsageBlock usage={it.usage} compact returnContext={mediaLibraryReturn} />
|
||||
</td>
|
||||
{viewer?.show_club_meta ? (
|
||||
<td className="media-library__td-sub">{it.club_name || it.club_id || '—'}</td>
|
||||
@@ -1333,7 +1338,7 @@ export default function MediaLibraryPage() {
|
||||
<div className="media-library__meta-block">
|
||||
<span className="media-library__meta-k">Verwendung</span>
|
||||
<div className="media-library__meta-v">
|
||||
<MediaUsageBlock usage={modal.usage} compact={false} />
|
||||
<MediaUsageBlock usage={modal.usage} compact={false} returnContext={mediaLibraryReturn} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Scale } from 'lucide-react'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import { SETTINGS_PATH } from '../utils/navReturnContext'
|
||||
|
||||
const LEGAL_LINKS = [
|
||||
{ to: '/impressum', label: 'Impressum', description: 'Angaben zum Betreiber und Verantwortlichen' },
|
||||
@@ -12,9 +14,7 @@ function SettingsLegalPage() {
|
||||
return (
|
||||
<div className="page-padding app-page" style={{ padding: '1rem' }}>
|
||||
<p style={{ marginBottom: '0.75rem' }}>
|
||||
<Link to="/settings" style={{ fontSize: '0.9rem' }}>
|
||||
← Zurück zu Einstellungen
|
||||
</Link>
|
||||
<PageReturnButton fallbackPath={SETTINGS_PATH} fallbackLabel="Zurück zu Einstellungen" />
|
||||
</p>
|
||||
|
||||
<h1 style={{ marginBottom: '0.35rem', fontSize: '1.5rem' }}>Rechtliches</h1>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import api from '../utils/api'
|
||||
import { SETTINGS_PATH } from '../utils/navReturnContext'
|
||||
|
||||
/**
|
||||
* Technische System- und Build-Infos (ehemals Dashboard) — unter Einstellungen für Betrieb/Diagnose.
|
||||
@@ -33,9 +34,7 @@ function SettingsSystemInfoPage() {
|
||||
return (
|
||||
<div className="page-padding app-page" style={{ padding: '1rem' }}>
|
||||
<p style={{ marginBottom: '0.75rem' }}>
|
||||
<Link to="/settings" style={{ fontSize: '0.9rem' }}>
|
||||
← Zurück zu Einstellungen
|
||||
</Link>
|
||||
<PageReturnButton fallbackPath={SETTINGS_PATH} fallbackLabel="Zurück zu Einstellungen" />
|
||||
</p>
|
||||
<h1 style={{ marginBottom: '0.35rem', fontSize: '1.5rem' }}>Systeminformationen</h1>
|
||||
<p
|
||||
|
||||
@@ -6,6 +6,11 @@ import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import ExerciseFullContent from '../components/ExerciseFullContent'
|
||||
import ExercisePeekModal from '../components/ExercisePeekModal'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import {
|
||||
buildPlanningHubFallbackReturnContext,
|
||||
buildTrainingRunReturnContext,
|
||||
} from '../utils/navReturnContext'
|
||||
import {
|
||||
COACH_ENTRY_BRANCH_GATE,
|
||||
buildCoachSavePlanPayload,
|
||||
@@ -184,6 +189,8 @@ export default function TrainingCoachPage() {
|
||||
const navigate = useNavigate()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const idNum = unitId ? parseInt(unitId, 10) : NaN
|
||||
const planningReturn = useMemo(() => buildPlanningHubFallbackReturnContext(), [])
|
||||
const runReturn = useMemo(() => buildTrainingRunReturnContext(unitId), [unitId])
|
||||
|
||||
const coachFocusResetRef = useRef(null)
|
||||
|
||||
@@ -667,9 +674,11 @@ export default function TrainingCoachPage() {
|
||||
return (
|
||||
<div className="card" style={{ margin: '1rem', padding: '1.5rem' }}>
|
||||
<p style={{ marginBottom: '1rem' }}>{loadError || 'Nicht gefunden.'}</p>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate('/planning')}>
|
||||
Zur Planung
|
||||
</button>
|
||||
<PageReturnButton
|
||||
fallbackPath={planningReturn.path}
|
||||
fallbackLabel={planningReturn.label}
|
||||
className="page-return-btn btn btn-secondary btn-small"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -680,6 +689,7 @@ export default function TrainingCoachPage() {
|
||||
key={candidatePeekId != null ? String(candidatePeekId) : 'coach-peek-closed'}
|
||||
open={candidatePeekId != null}
|
||||
exerciseId={candidatePeekId}
|
||||
returnContext={runReturn}
|
||||
onClose={() => setCandidatePeekId(null)}
|
||||
/>
|
||||
<nav
|
||||
@@ -697,9 +707,11 @@ export default function TrainingCoachPage() {
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate(`/planning/run/${unitId}`)}>
|
||||
Zur Planansicht
|
||||
</button>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate('/planning')}>
|
||||
Planung
|
||||
</button>
|
||||
<PageReturnButton
|
||||
fallbackPath={planningReturn.path}
|
||||
fallbackLabel={planningReturn.label}
|
||||
className="page-return-btn btn btn-secondary btn-small"
|
||||
/>
|
||||
{streamFocusOptions.length > 0 ? (
|
||||
<label
|
||||
className="no-print"
|
||||
|
||||
@@ -6,7 +6,14 @@ import ExercisePeekModal from '../components/ExercisePeekModal'
|
||||
import TrainingUnitSectionsEditor from '../components/TrainingUnitSectionsEditor'
|
||||
import PageSectionNav from '../components/PageSectionNav'
|
||||
import FormActionBar from '../components/FormActionBar'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import { useToast } from '../context/ToastContext'
|
||||
import { useNavReturn } from '../hooks/useNavReturn'
|
||||
import {
|
||||
FRAMEWORK_PROGRAMS_LIST_PATH,
|
||||
buildFrameworkProgramsListReturnContext,
|
||||
preserveAppReturnOnNavigate,
|
||||
} from '../utils/navReturnContext'
|
||||
import UnsavedChangesPrompt from '../components/UnsavedChangesPrompt'
|
||||
import { useBeforeUnloadWhen, useUnsavedChangesBlocker } from '../hooks/useUnsavedChangesBlocker'
|
||||
import {
|
||||
@@ -212,6 +219,8 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
const { id: idParam } = useParams()
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const frameworkListReturn = useMemo(() => buildFrameworkProgramsListReturnContext(), [])
|
||||
const { goBack } = useNavReturn(frameworkListReturn)
|
||||
/** Route `…/framework-programs/new` hat kein dynamisches `:id` — useParams ist dann leer. */
|
||||
const isNew = /\/framework-programs\/new\/?$/.test(location.pathname)
|
||||
|
||||
@@ -328,7 +337,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
}
|
||||
const fid = parseInt(idParam, 10)
|
||||
if (Number.isNaN(fid)) {
|
||||
navigate('/planning/framework-programs', { replace: true })
|
||||
navigate(FRAMEWORK_PROGRAMS_LIST_PATH, { replace: true })
|
||||
return
|
||||
}
|
||||
setLoading(true)
|
||||
@@ -342,7 +351,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
setForm(next)
|
||||
} catch (e) {
|
||||
toast.error(e.message || 'Laden fehlgeschlagen')
|
||||
navigate('/planning/framework-programs')
|
||||
goBack()
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false)
|
||||
}
|
||||
@@ -450,9 +459,11 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
const created = await api.createTrainingFrameworkProgram(payload)
|
||||
toast.success('Rahmenprogramm angelegt.')
|
||||
if (closeAfter) {
|
||||
navigate('/planning/framework-programs')
|
||||
goBack()
|
||||
} else if (!fromUnsavedDialog) {
|
||||
navigate(`/planning/framework-programs/${created.id}`, { replace: true })
|
||||
preserveAppReturnOnNavigate(navigate, location, `/planning/framework-programs/${created.id}`, {
|
||||
replace: true,
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -466,7 +477,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
setBypassDirty(false)
|
||||
setBaselineReady(true)
|
||||
toast.success('Gespeichert.')
|
||||
if (closeAfter) navigate('/planning/framework-programs')
|
||||
if (closeAfter) goBack()
|
||||
return true
|
||||
} catch (e) {
|
||||
toast.error(e.message || 'Speichern fehlgeschlagen')
|
||||
@@ -495,7 +506,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
if (!confirm('Dieses Rahmenprogramm wirklich löschen?')) return
|
||||
try {
|
||||
await api.deleteTrainingFrameworkProgram(fid)
|
||||
navigate('/planning/framework-programs')
|
||||
goBack()
|
||||
} catch (e) {
|
||||
toast.error(e.message || 'Löschen fehlgeschlagen')
|
||||
}
|
||||
@@ -846,11 +857,10 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
return (
|
||||
<div className="app-page">
|
||||
<div className="framework-edit">
|
||||
<p style={{ marginBottom: '0.75rem' }}>
|
||||
<Link to="/planning/framework-programs" style={{ color: 'var(--accent-dark)' }}>
|
||||
← Alle Rahmenprogramme
|
||||
</Link>
|
||||
</p>
|
||||
<PageReturnButton
|
||||
fallbackPath={FRAMEWORK_PROGRAMS_LIST_PATH}
|
||||
fallbackLabel="Zurück zu Rahmenprogrammen"
|
||||
/>
|
||||
|
||||
<h1 style={{ marginBottom: '0.75rem' }}>{isNew ? 'Neues Rahmenprogramm' : 'Rahmenprogramm bearbeiten'}</h1>
|
||||
|
||||
@@ -1263,7 +1273,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
saving={saving}
|
||||
onSave={handleSave}
|
||||
onSaveAndClose={handleSaveAndClose}
|
||||
onCancel={() => navigate('/planning/framework-programs')}
|
||||
onCancel={goBack}
|
||||
cancelLabel="Abbrechen"
|
||||
/>
|
||||
{!isNew ? (
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { buildFrameworkProgramsListReturnContext } from '../utils/navReturnContext'
|
||||
|
||||
function dashIfEmpty(val) {
|
||||
const s = (val ?? '').toString().trim()
|
||||
@@ -59,6 +60,7 @@ function FrameworkSummaryMeta({ r }) {
|
||||
export default function TrainingFrameworkProgramsListPage() {
|
||||
const { user } = useAuth()
|
||||
const tenantClubDepKey = useMemo(() => getTenantClubDependencyKey(user), [user])
|
||||
const frameworkListReturn = useMemo(() => buildFrameworkProgramsListReturnContext(), [])
|
||||
const [rows, setRows] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
@@ -119,13 +121,14 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<Link
|
||||
<NavStateLink
|
||||
to="/planning/framework-programs/new"
|
||||
returnContext={frameworkListReturn}
|
||||
className="btn btn-primary"
|
||||
style={{ textDecoration: 'none', whiteSpace: 'nowrap' }}
|
||||
>
|
||||
Rahmenprogramm anlegen
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
@@ -145,13 +148,14 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
Noch kein Rahmenprogramm gespeichert. Lege ein neues an — mit Titel, mindestens einem Ziel und optional
|
||||
Slots samt Übungen.
|
||||
</p>
|
||||
<Link
|
||||
<NavStateLink
|
||||
to="/planning/framework-programs/new"
|
||||
returnContext={frameworkListReturn}
|
||||
className="btn btn-primary btn-full"
|
||||
style={{ textDecoration: 'none' }}
|
||||
>
|
||||
Rahmenprogramm anlegen
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
</div>
|
||||
) : (
|
||||
<ul className="framework-programs-list">
|
||||
@@ -167,12 +171,13 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
}}
|
||||
>
|
||||
<div style={{ minWidth: 0, flex: '1 1 220px' }}>
|
||||
<Link
|
||||
<NavStateLink
|
||||
to={`/planning/framework-programs/${r.id}`}
|
||||
returnContext={frameworkListReturn}
|
||||
style={{ fontWeight: 600, fontSize: '1.05rem', color: 'var(--text1)' }}
|
||||
>
|
||||
{r.title || `Rahmen #${r.id}`}
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
<div style={{ fontSize: '0.85rem', color: 'var(--text2)', marginTop: '0.35rem' }}>
|
||||
<span>
|
||||
{(r.goals_count ?? '—') + ' Ziele · '}
|
||||
@@ -182,13 +187,14 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
<FrameworkSummaryMeta r={r} />
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
|
||||
<Link
|
||||
<NavStateLink
|
||||
to={`/planning/framework-programs/${r.id}`}
|
||||
returnContext={frameworkListReturn}
|
||||
className="btn btn-secondary"
|
||||
style={{ textDecoration: 'none' }}
|
||||
>
|
||||
Bearbeiten
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => handleDelete(r.id, r.title)}>
|
||||
Löschen
|
||||
</button>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import ExercisePickerModal from '../components/ExercisePickerModal'
|
||||
import FormActionBar from '../components/FormActionBar'
|
||||
import PageReturnLink from '../components/PageReturnLink'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import { hydrateExercisePlanningRow } from '../utils/trainingUnitSectionsForm'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { useToast } from '../context/ToastContext'
|
||||
@@ -377,7 +377,7 @@ export default function TrainingModuleEditPage() {
|
||||
|
||||
return (
|
||||
<div className="app-page">
|
||||
<PageReturnLink
|
||||
<PageReturnButton
|
||||
fallbackPath={TRAINING_MODULES_LIST_PATH}
|
||||
fallbackLabel="Zurück zur Modul-Bibliothek"
|
||||
/>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { buildTrainingModulesListReturnContext } from '../utils/navReturnContext'
|
||||
|
||||
export default function TrainingModulesListPage() {
|
||||
const { user } = useAuth()
|
||||
const tenantClubDepKey = useMemo(() => getTenantClubDependencyKey(user), [user])
|
||||
const modulesListReturn = useMemo(() => buildTrainingModulesListReturnContext(), [])
|
||||
const [rows, setRows] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
@@ -60,9 +62,14 @@ export default function TrainingModulesListPage() {
|
||||
lokale Kopie (mit Herkunftsmarkierung).
|
||||
</p>
|
||||
</div>
|
||||
<Link to="/planning/training-modules/new" className="btn btn-primary" style={{ textDecoration: 'none' }}>
|
||||
<NavStateLink
|
||||
to="/planning/training-modules/new"
|
||||
returnContext={modulesListReturn}
|
||||
className="btn btn-primary"
|
||||
style={{ textDecoration: 'none' }}
|
||||
>
|
||||
Neues Modul
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
</div>
|
||||
|
||||
{error ? (
|
||||
@@ -88,8 +95,9 @@ export default function TrainingModulesListPage() {
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: '1 1 220px', minWidth: 0 }}>
|
||||
<Link
|
||||
<NavStateLink
|
||||
to={`/planning/training-modules/${r.id}`}
|
||||
returnContext={modulesListReturn}
|
||||
style={{
|
||||
fontWeight: 700,
|
||||
fontSize: '1.05rem',
|
||||
@@ -99,7 +107,7 @@ export default function TrainingModulesListPage() {
|
||||
}}
|
||||
>
|
||||
{(r.title || '').trim() || `Modul #${r.id}`}
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
<p style={{ margin: '0.35rem 0 0', fontSize: '0.88rem', color: 'var(--text2)', lineHeight: 1.45 }}>
|
||||
{(r.summary || '').trim() || '—'}{' '}
|
||||
<span style={{ color: 'var(--text3)' }}>
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import TrainingUnitSectionsEditor from '../components/TrainingUnitSectionsEditor'
|
||||
import FormActionBar from '../components/FormActionBar'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import UnsavedChangesPrompt from '../components/UnsavedChangesPrompt'
|
||||
import { useBeforeUnloadWhen, useUnsavedChangesBlocker } from '../hooks/useUnsavedChangesBlocker'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { useToast } from '../context/ToastContext'
|
||||
import { useNavReturn } from '../hooks/useNavReturn'
|
||||
import {
|
||||
PLAN_TEMPLATES_LIST_PATH,
|
||||
buildPlanTemplatesListReturnContext,
|
||||
} from '../utils/navReturnContext'
|
||||
import {
|
||||
defaultSection,
|
||||
formSectionsFromPlanTemplateRows,
|
||||
@@ -31,6 +37,8 @@ function templateFormSnapshot({ name, description, visibility, clubIdField, sect
|
||||
export default function TrainingPlanTemplateEditPage() {
|
||||
const { id: routeId } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const templatesListReturn = useMemo(() => buildPlanTemplatesListReturnContext(), [])
|
||||
const { goBack } = useNavReturn(templatesListReturn)
|
||||
const templateId = parseInt(routeId, 10)
|
||||
const toast = useToast()
|
||||
const { user } = useAuth()
|
||||
@@ -183,7 +191,7 @@ export default function TrainingPlanTemplateEditPage() {
|
||||
baselineRef.current = templateFormSnapshot(latestFormRef.current)
|
||||
setBypassDirty(false)
|
||||
toast.success('Vorlage gespeichert.')
|
||||
if (closeAfter) navigate('/planning/plan-templates')
|
||||
if (closeAfter) goBack()
|
||||
return true
|
||||
} catch (err) {
|
||||
const msg = err.message || 'Speichern fehlgeschlagen'
|
||||
@@ -220,11 +228,10 @@ export default function TrainingPlanTemplateEditPage() {
|
||||
|
||||
return (
|
||||
<div className="app-page">
|
||||
<p style={{ marginBottom: '0.75rem' }}>
|
||||
<Link to="/planning/plan-templates" style={{ color: 'var(--accent-dark)', fontWeight: 600 }}>
|
||||
← Zurück zu Vorlagen
|
||||
</Link>
|
||||
</p>
|
||||
<PageReturnButton
|
||||
fallbackPath={PLAN_TEMPLATES_LIST_PATH}
|
||||
fallbackLabel="Zurück zu Vorlagen"
|
||||
/>
|
||||
|
||||
<h1 className="page-title" style={{ marginBottom: '0.35rem' }}>
|
||||
Trainingsvorlage bearbeiten
|
||||
@@ -321,7 +328,7 @@ export default function TrainingPlanTemplateEditPage() {
|
||||
variant="page"
|
||||
formId="plan-template-form"
|
||||
saving={saving}
|
||||
onCancel={() => navigate('/planning/plan-templates')}
|
||||
onCancel={goBack}
|
||||
onSaveAndClose={handleSaveAndClose}
|
||||
/>
|
||||
</form>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { useToast } from '../context/ToastContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { canDeleteLibraryContent, canEditLibraryContent } from '../utils/libraryContentPermissions'
|
||||
import PlanTemplateStructurePreview from '../components/planning/PlanTemplateStructurePreview'
|
||||
import { buildPlanTemplatesListReturnContext } from '../utils/navReturnContext'
|
||||
|
||||
function visibilityLabel(v) {
|
||||
const x = String(v || 'club').toLowerCase()
|
||||
@@ -16,6 +17,7 @@ function visibilityLabel(v) {
|
||||
|
||||
export default function TrainingPlanTemplatesListPage() {
|
||||
const { user } = useAuth()
|
||||
const templatesListReturn = useMemo(() => buildPlanTemplatesListReturnContext(), [])
|
||||
const toast = useToast()
|
||||
const tenantClubDepKey = useMemo(() => getTenantClubDependencyKey(user), [user])
|
||||
const [rows, setRows] = useState([])
|
||||
@@ -113,8 +115,9 @@ export default function TrainingPlanTemplatesListPage() {
|
||||
>
|
||||
<div style={{ minWidth: 0, flex: '1 1 240px' }}>
|
||||
{canEdit ? (
|
||||
<Link
|
||||
<NavStateLink
|
||||
to={`/planning/plan-templates/${t.id}`}
|
||||
returnContext={templatesListReturn}
|
||||
style={{
|
||||
fontWeight: 700,
|
||||
fontSize: '1rem',
|
||||
@@ -124,7 +127,7 @@ export default function TrainingPlanTemplatesListPage() {
|
||||
}}
|
||||
>
|
||||
{(t.name || '').trim() || `Vorlage #${t.id}`}
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
) : (
|
||||
<strong style={{ color: 'var(--text1)', fontSize: '1rem', wordBreak: 'break-word' }}>
|
||||
{(t.name || '').trim() || `Vorlage #${t.id}`}
|
||||
@@ -157,13 +160,14 @@ export default function TrainingPlanTemplatesListPage() {
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px', flexShrink: 0 }}>
|
||||
{canEdit ? (
|
||||
<Link
|
||||
<NavStateLink
|
||||
className="btn btn-secondary"
|
||||
style={{ textDecoration: 'none' }}
|
||||
to={`/planning/plan-templates/${t.id}`}
|
||||
returnContext={templatesListReturn}
|
||||
>
|
||||
Bearbeiten
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
) : (
|
||||
<span style={{ fontSize: '0.82rem', color: 'var(--text3)', alignSelf: 'center' }}>
|
||||
nur Lesen
|
||||
|
||||
@@ -32,8 +32,12 @@ import {
|
||||
import PageFormEditorChrome from '../components/PageFormEditorChrome'
|
||||
import UnsavedChangesPrompt from '../components/UnsavedChangesPrompt'
|
||||
import { useBeforeUnloadWhen, useUnsavedChangesBlocker } from '../hooks/useUnsavedChangesBlocker'
|
||||
import { buildPlanUnitEditPath, planningHubPathFromReturnState } from '../utils/planningUnitRoutes'
|
||||
import { goNavReturn, buildCurrentLocationReturnContext } from '../utils/navReturnContext'
|
||||
import { buildPlanUnitEditPath } from '../utils/planningUnitRoutes'
|
||||
import {
|
||||
PLANNING_HUB_PATH,
|
||||
buildCurrentLocationReturnContext,
|
||||
goNavReturn,
|
||||
} from '../utils/navReturnContext'
|
||||
|
||||
export default function TrainingUnitEditPage() {
|
||||
const { id: routeId } = useParams()
|
||||
@@ -121,7 +125,7 @@ export default function TrainingUnitEditPage() {
|
||||
|
||||
const goBack = useCallback(() => {
|
||||
goNavReturn(navigate, location, {
|
||||
path: planningHubPathFromReturnState(location.state?.planningReturn),
|
||||
path: PLANNING_HUB_PATH,
|
||||
label: 'Zurück zur Planung',
|
||||
})
|
||||
}, [location, navigate])
|
||||
@@ -526,7 +530,7 @@ export default function TrainingUnitEditPage() {
|
||||
[saving, editingUnit, handleSubmit, goBack]
|
||||
)
|
||||
|
||||
const hubBackPath = planningHubPathFromReturnState(location.state?.planningReturn)
|
||||
const hubBackPath = PLANNING_HUB_PATH
|
||||
const pageTitle = editingUnit ? 'Trainingseinheit bearbeiten' : 'Neue Trainingseinheit'
|
||||
|
||||
const handleSaveAsTemplate = async (opts = {}) => {
|
||||
@@ -659,8 +663,8 @@ export default function TrainingUnitEditPage() {
|
||||
<PageFormEditorChrome
|
||||
testId="planning-unit-form"
|
||||
title={pageTitle}
|
||||
backTo={hubBackPath}
|
||||
backLabel="Trainingsplanung"
|
||||
fallbackPath={hubBackPath}
|
||||
fallbackLabel="Zurück zur Planung"
|
||||
actionConfig={actionConfig}
|
||||
>
|
||||
<TrainingUnitFormShell
|
||||
@@ -732,6 +736,7 @@ export default function TrainingUnitEditPage() {
|
||||
onSuccess={() => setPublishFrameworkOpen(false)}
|
||||
unitId={editingUnit?.id}
|
||||
planningModalClubId={planningClubId}
|
||||
returnContext={moduleSaveReturnContext}
|
||||
/>
|
||||
|
||||
<SaveExercisesAsModuleModal
|
||||
|
||||
@@ -3,10 +3,16 @@
|
||||
* Phasen: Ganzgruppe vs. Split (planLoc); Druck mit optional getrennten Breakout-Seiten.
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
import { Link, useParams } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import ExercisePeekModal from '../components/ExercisePeekModal'
|
||||
import PageReturnButton from '../components/PageReturnButton'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import CombinationPlanBracket from '../components/CombinationPlanBracket'
|
||||
import {
|
||||
buildPlanningHubFallbackReturnContext,
|
||||
buildTrainingRunReturnContext,
|
||||
} from '../utils/navReturnContext'
|
||||
import {
|
||||
buildPlanRunViewModelFromSections,
|
||||
itemStableKey,
|
||||
@@ -34,8 +40,9 @@ function statusLabel(s) {
|
||||
|
||||
export default function TrainingUnitRunPage() {
|
||||
const { unitId } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const idNum = unitId ? parseInt(unitId, 10) : NaN
|
||||
const planningReturn = useMemo(() => buildPlanningHubFallbackReturnContext(), [])
|
||||
const runReturn = useMemo(() => buildTrainingRunReturnContext(unitId), [unitId])
|
||||
|
||||
const [unit, setUnit] = useState(null)
|
||||
const [loadError, setLoadError] = useState(null)
|
||||
@@ -337,12 +344,13 @@ export default function TrainingUnitRunPage() {
|
||||
>
|
||||
Katalog (Popup)
|
||||
</button>
|
||||
<Link
|
||||
<NavStateLink
|
||||
to={`/exercises/${it.exercise_id}`}
|
||||
returnContext={runReturn}
|
||||
style={{ fontSize: '0.82rem', color: 'var(--accent)' }}
|
||||
>
|
||||
Vollständige Seite öffnen
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
</div>
|
||||
)}
|
||||
</span>
|
||||
@@ -368,9 +376,11 @@ export default function TrainingUnitRunPage() {
|
||||
return (
|
||||
<div className="card" style={{ margin: '1rem', padding: '1.5rem' }}>
|
||||
<p style={{ marginBottom: '1rem' }}>{loadError || 'Trainingseinheit nicht gefunden.'}</p>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate('/planning')}>
|
||||
Zur Planung
|
||||
</button>
|
||||
<PageReturnButton
|
||||
fallbackPath={planningReturn.path}
|
||||
fallbackLabel={planningReturn.label}
|
||||
className="page-return-btn btn btn-secondary btn-small"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -382,6 +392,7 @@ export default function TrainingUnitRunPage() {
|
||||
exerciseId={peekCtx?.exerciseId}
|
||||
variantId={peekCtx?.variantId ?? undefined}
|
||||
peekExtras={peekCtx?.peekExtras ?? undefined}
|
||||
returnContext={runReturn}
|
||||
onClose={() => setPeekCtx(null)}
|
||||
/>
|
||||
|
||||
@@ -395,11 +406,14 @@ export default function TrainingUnitRunPage() {
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate('/planning')}>
|
||||
Zur Planung
|
||||
</button>
|
||||
<Link
|
||||
<PageReturnButton
|
||||
fallbackPath={planningReturn.path}
|
||||
fallbackLabel={planningReturn.label}
|
||||
className="page-return-btn btn btn-secondary btn-small"
|
||||
/>
|
||||
<NavStateLink
|
||||
to={`/planning/run/${unitId}/coach`}
|
||||
returnContext={runReturn}
|
||||
className="btn btn-primary"
|
||||
style={{
|
||||
textDecoration: 'none',
|
||||
@@ -409,7 +423,7 @@ export default function TrainingUnitRunPage() {
|
||||
}}
|
||||
>
|
||||
Im Training (Coach)
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => window.print()}>
|
||||
Drucken / PDF
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user