Initial commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { fetchProgress } from '../api/lessons';
|
||||
import type { ProgressSummary } from '../api/types';
|
||||
import { ScoreBadge } from '../components/ScoreBadge';
|
||||
|
||||
export function ProgressPage() {
|
||||
const [progress, setProgress] = useState<ProgressSummary | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
fetchProgress().then(setProgress).catch((err) => setError(err instanceof Error ? err.message : 'Fortschritt konnte nicht geladen werden'));
|
||||
}, []);
|
||||
|
||||
if (error) return <p className="form-error">{error}</p>;
|
||||
if (!progress) return <p className="muted">Lade Fortschritt...</p>;
|
||||
|
||||
return (
|
||||
<div className="view-stack">
|
||||
<header className="view-header">
|
||||
<div>
|
||||
<p className="eyebrow">A1 Englisch</p>
|
||||
<h1>Fortschritt</h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section className="metric-grid">
|
||||
<div className="panel result-panel">
|
||||
<ScoreBadge label="Durchschnitt" value={progress.average_score} />
|
||||
</div>
|
||||
<div className="panel metric">
|
||||
<span>Versuche</span>
|
||||
<strong>{progress.total_attempts}</strong>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="panel result-panel">
|
||||
<h2>Schwierige Woerter</h2>
|
||||
<div className="weak-list">
|
||||
{(progress.weak_words ?? []).length === 0 ? (
|
||||
<p className="muted">Noch keine Schwachstellen.</p>
|
||||
) : (
|
||||
(progress.weak_words ?? []).map((word) => (
|
||||
<span className={`word word-${word.highlight}`} key={word.word}>
|
||||
{word.word} {Math.round(word.accuracy)}
|
||||
</span>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="panel result-panel">
|
||||
<h2>Letzte Versuche</h2>
|
||||
<div className="attempt-list">
|
||||
{(progress.recent_attempts ?? []).map((attempt) => (
|
||||
<div className="attempt-row" key={attempt.id}>
|
||||
<span>{new Date(attempt.created_at).toLocaleString()}</span>
|
||||
<strong>{Math.round(attempt.overall_score)}</strong>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user