feat: EP-Fortschritt speichern + echtes Profil
- saveProgress/getUserProgress (POST /auth/progress, /auth/me) - Feed: onComplete bucht EP, EP-Zähler oben - Profil: echte total_ep/level/streak statt hartkodiert Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -135,14 +135,15 @@ export default function Profil() {
|
||||
load()
|
||||
}, [token, user.username])
|
||||
|
||||
const displayName = profil?.username?.username_public || user?.username || '…'
|
||||
const displayName = profil?.username || user?.username || '…'
|
||||
const initials = displayName.slice(0, 2).toUpperCase()
|
||||
const points = pair?.points ?? profil?.points_total ?? 0
|
||||
const level = pair?.current_level ?? 1
|
||||
const xpMax = level * 500
|
||||
const xpPct = Math.min((points / xpMax) * 100, 100)
|
||||
const toLang = pair ? langById(pair.language_to, langs) : null
|
||||
const langLabel = toLang ? `${toLang.flag} ${toLang.label}` : 'Zielsprache'
|
||||
const points = profil?.total_ep ?? 0
|
||||
const level = profil?.level ?? Math.floor(points / 500)
|
||||
const epIntoLevel = points - level * 500 // EP innerhalb des aktuellen Levels
|
||||
const epPerLevel = 500
|
||||
const xpPct = Math.min((epIntoLevel / epPerLevel) * 100, 100)
|
||||
const toLang = profil?.language_target_short ? langById(profil.language_target_id, langs) : null
|
||||
const langLabel = toLang ? `${toLang.flag} ${toLang.label}` : (profil?.language_target_titel || 'Zielsprache')
|
||||
const streak = profil?.streak_days ?? 0
|
||||
|
||||
return (
|
||||
@@ -193,7 +194,7 @@ export default function Profil() {
|
||||
|
||||
<div className="xp-row">
|
||||
<span className="lang-label">{langLabel}</span>
|
||||
<span className="xp-value">{points.toLocaleString('de')} / {xpMax.toLocaleString('de')} XP</span>
|
||||
<span className="xp-value">{points.toLocaleString('de')} EP gesamt</span>
|
||||
</div>
|
||||
|
||||
<div className="xp-bar">
|
||||
@@ -202,7 +203,7 @@ export default function Profil() {
|
||||
|
||||
<div className="level-row">
|
||||
<span className="level-pill">Level {level}</span>
|
||||
<span className="level-hint">{(xpMax - points).toLocaleString('de')} XP bis Level {level + 1}</span>
|
||||
<span className="level-hint">{(epPerLevel - epIntoLevel).toLocaleString('de')} EP bis Level {level + 1}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user