feat: add TrainingCoachPage and enhance training planning features
- Introduced TrainingCoachPage for coaching-related training sessions. - Updated app routing to include a new route for the TrainingCoachPage. - Enhanced TrainingPlanningPage with a link to navigate to the new coaching page. - Incremented version numbers for TrainingPlanningPage, TrainingUnitRunPage, and added version for TrainingCoachPage. - Integrated ExercisePeekModal for improved exercise selection and visibility in both TrainingPlanningPage and TrainingUnitRunPage.
This commit is contained in:
1 parent
8debdae397
commit
3673053fe2
7 files changed
+838
-24
No files matched your search
@@ -4,28 +4,13 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import ExercisePeekModal from '../components/ExercisePeekModal'
|
||||
import { itemStableKey, sortedSections, sortedItems } from '../utils/trainingPlanUtils'
|
||||
|
||||
function storageKey(unitId) {
|
||||
return `sj_training_run_checked_${unitId}`
|
||||
}
|
||||
|
||||
function itemStableKey(it, secOrder, ix) {
|
||||
if (it && it.id != null) return String(it.id)
|
||||
return `${secOrder}-${it?.item_type || 'row'}-${ix}`
|
||||
}
|
||||
|
||||
function sortedSections(unit) {
|
||||
const raw = unit?.sections
|
||||
if (!Array.isArray(raw)) return []
|
||||
return [...raw].sort((a, b) => (a.order_index ?? 0) - (b.order_index ?? 0))
|
||||
}
|
||||
|
||||
function sortedItems(sec) {
|
||||
const raw = sec?.items
|
||||
if (!Array.isArray(raw)) return []
|
||||
return [...raw].sort((a, b) => (a.order_index ?? 0) - (b.order_index ?? 0))
|
||||
}
|
||||
|
||||
function formatMin(m) {
|
||||
if (m === null || m === undefined || m === '') return null
|
||||
const n = Number(m)
|
||||
@@ -48,6 +33,7 @@ export default function TrainingUnitRunPage() {
|
||||
const [loadError, setLoadError] = useState(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [checked, setChecked] = useState(() => new Set())
|
||||
const [peekExerciseId, setPeekExerciseId] = useState(null)
|
||||
|
||||
const loadChecked = useCallback((uid) => {
|
||||
try {
|
||||
@@ -156,11 +142,24 @@ export default function TrainingUnitRunPage() {
|
||||
|
||||
return (
|
||||
<div className="training-run-page" style={{ maxWidth: '720px', margin: '0 auto', paddingBottom: '2rem' }}>
|
||||
<nav className="training-run-toolbar no-print" style={{ marginBottom: '1rem', display: 'flex', gap: '0.5rem', flexWrap: 'wrap' }}>
|
||||
<ExercisePeekModal
|
||||
open={peekExerciseId != null}
|
||||
exerciseId={peekExerciseId}
|
||||
onClose={() => setPeekExerciseId(null)}
|
||||
/>
|
||||
|
||||
<nav className="training-run-toolbar no-print" style={{ marginBottom: '1rem', display: 'flex', gap: '0.5rem', flexWrap: 'wrap', alignItems: 'center' }}>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => navigate('/planning')}>
|
||||
Zur Planung
|
||||
</button>
|
||||
<button type="button" className="btn btn-primary" onClick={() => window.print()}>
|
||||
<Link
|
||||
to={`/planning/run/${unitId}/coach`}
|
||||
className="btn btn-primary"
|
||||
style={{ textDecoration: 'none', display: 'inline-flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
>
|
||||
Im Training (Coach)
|
||||
</Link>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => window.print()}>
|
||||
Drucken / PDF
|
||||
</button>
|
||||
<button type="button" className="btn btn-secondary" title="Alle Häkchen auf dieser Matte zurücksetzen" onClick={() => confirm('Fortschritt wirklich zurücksetzen?') && clearProgress()}>
|
||||
@@ -310,9 +309,20 @@ export default function TrainingUnitRunPage() {
|
||||
</div>
|
||||
)}
|
||||
{it.exercise_id && (
|
||||
<div className="no-print" style={{ marginTop: '0.5rem' }}>
|
||||
<Link to={`/exercises/${it.exercise_id}`} style={{ fontSize: '0.82rem', color: 'var(--accent)' }}>
|
||||
Zur Übung im Katalog
|
||||
<div className="no-print" style={{ display: 'flex', flexWrap: 'wrap', gap: '10px', marginTop: '0.55rem', alignItems: 'center' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '0.82rem', margin: 0 }}
|
||||
onClick={() => setPeekExerciseId(it.exercise_id)}
|
||||
>
|
||||
Katalog (Popup)
|
||||
</button>
|
||||
<Link
|
||||
to={`/exercises/${it.exercise_id}`}
|
||||
style={{ fontSize: '0.82rem', color: 'var(--accent)' }}
|
||||
>
|
||||
Vollständige Seite öffnen
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user