feat(profiles): add training planning preferences to user profile
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 56s
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 56s
- Introduced `training_planning_prefs` field in the ProfileUpdate model to store user-specific UI options for training planning. - Updated the backend to handle the new preferences during profile updates, ensuring proper validation and storage. - Enhanced the frontend to allow users to select their preferred display mode for training modules in the Account Settings page. - Updated version to 0.8.98 and adjusted database schema version accordingly, reflecting the new feature integration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
05042ee9ec
commit
f4f5642c21
7 files changed
+140
-20
No files matched your search
@@ -1,6 +1,10 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import {
|
||||
PLANNING_MODULE_DISPLAY_MODES,
|
||||
resolvePlanningModuleDisplayMode,
|
||||
} from '../config/planningModuleUx'
|
||||
import api from '../utils/api'
|
||||
|
||||
/**
|
||||
@@ -17,6 +21,12 @@ function AccountSettingsPage() {
|
||||
const [joinMessage, setJoinMessage] = useState('')
|
||||
const [joinBusy, setJoinBusy] = useState(false)
|
||||
|
||||
const [planningPrefsBusy, setPlanningPrefsBusy] = useState(false)
|
||||
/** @type {[string, React.Dispatch<React.SetStateAction<string>>]} */
|
||||
const [moduleDisplayDraft, setModuleDisplayDraft] = useState(
|
||||
PLANNING_MODULE_DISPLAY_MODES.COMPACT_TAG_LEGEND
|
||||
)
|
||||
|
||||
const [newPw1, setNewPw1] = useState('')
|
||||
const [newPw2, setNewPw2] = useState('')
|
||||
const [savingPw, setSavingPw] = useState(false)
|
||||
@@ -29,6 +39,11 @@ function AccountSettingsPage() {
|
||||
setName(typeof user?.name === 'string' ? user.name : '')
|
||||
}, [user])
|
||||
|
||||
useEffect(() => {
|
||||
const m = resolvePlanningModuleDisplayMode(user?.training_planning_prefs?.module_display_mode)
|
||||
setModuleDisplayDraft(m)
|
||||
}, [user?.id, user?.training_planning_prefs])
|
||||
|
||||
const refreshJoinRequests = () => {
|
||||
api.getMyClubJoinRequests().then(setMyJoinRequests).catch(() => {})
|
||||
}
|
||||
@@ -93,6 +108,26 @@ function AccountSettingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleSavePlanningPrefs = async (e) => {
|
||||
e.preventDefault()
|
||||
if (!user?.id) return
|
||||
setPlanningPrefsBusy(true)
|
||||
try {
|
||||
const base =
|
||||
user.training_planning_prefs && typeof user.training_planning_prefs === 'object'
|
||||
? { ...user.training_planning_prefs }
|
||||
: {}
|
||||
const merged = { ...base, module_display_mode: moduleDisplayDraft }
|
||||
await api.updateProfile(user.id, { training_planning_prefs: merged })
|
||||
await checkAuth()
|
||||
showOk('Planungs-Anzeige gespeichert.')
|
||||
} catch (err) {
|
||||
showErr(err.message || 'Konnte nicht speichern.')
|
||||
} finally {
|
||||
setPlanningPrefsBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleResendVerification = async () => {
|
||||
const em = user?.email
|
||||
if (!em) return
|
||||
@@ -276,6 +311,49 @@ function AccountSettingsPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card" style={{ marginBottom: '1rem' }}>
|
||||
<h2 style={{ margin: '0 0 0.75rem', fontSize: '1.1rem' }}>Trainingsplanung</h2>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.875rem', marginBottom: '1rem', lineHeight: 1.5 }}>
|
||||
Wie kopiert aus der Modul-Bibliothek übernommenen Blöcken in einer Einheit dargestellt werden.
|
||||
</p>
|
||||
<form onSubmit={handleSavePlanningPrefs}>
|
||||
<fieldset style={{ margin: 0, padding: 0, border: 'none' }}>
|
||||
<legend className="form-label" style={{ marginBottom: '0.5rem' }}>
|
||||
Darstellung „Aus Modul“
|
||||
</legend>
|
||||
<label
|
||||
style={{ display: 'flex', gap: '0.5rem', alignItems: 'flex-start', cursor: 'pointer', marginBottom: '0.65rem' }}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="planning-module-display"
|
||||
checked={moduleDisplayDraft === PLANNING_MODULE_DISPLAY_MODES.COMPACT_TAG_LEGEND}
|
||||
onChange={() => setModuleDisplayDraft(PLANNING_MODULE_DISPLAY_MODES.COMPACT_TAG_LEGEND)}
|
||||
/>
|
||||
<span style={{ lineHeight: 1.45, fontSize: '0.9rem', color: 'var(--text1)' }}>
|
||||
<strong>Kompakt</strong> — farbige Markierung je Modul, Tag pro Zeile, Legende im Abschnitt.
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
style={{ display: 'flex', gap: '0.5rem', alignItems: 'flex-start', cursor: 'pointer', marginBottom: '0.75rem' }}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="planning-module-display"
|
||||
checked={moduleDisplayDraft === PLANNING_MODULE_DISPLAY_MODES.FULL_OUTLINE_HEADERS}
|
||||
onChange={() => setModuleDisplayDraft(PLANNING_MODULE_DISPLAY_MODES.FULL_OUTLINE_HEADERS)}
|
||||
/>
|
||||
<span style={{ lineHeight: 1.45, fontSize: '0.9rem', color: 'var(--text1)' }}>
|
||||
<strong>Ausführlich</strong> — großer Modul-Kopfbereich mit nummerierter Übungsliste.
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
<button type="submit" className="btn btn-secondary" disabled={planningPrefsBusy}>
|
||||
{planningPrefsBusy ? 'Speichern…' : 'Anzeige speichern'}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div className="card" style={{ marginBottom: '1rem' }}>
|
||||
<h2 style={{ margin: '0 0 0.75rem', fontSize: '1.1rem' }}>Vereinsbeitritt</h2>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.875rem', marginBottom: '1rem', lineHeight: 1.5 }}>
|
||||
|
||||
Reference in new issue
Block a user