{t('stats_title')}
{t('stats_sub')}
'use client'; import { useApp } from '@/app/providers'; import { TopBar } from '@/components/TopBar'; import { useProgress } from '@/lib/progress'; export interface SubjectStats { id: string; key: string; lessons: { id: string; number: number; titleKey: string | null; title: string | null; taskCount: number; }[]; } /** * Progress overview: totals at the top, then a bar per subject and a per-lesson * breakdown, following the layout of the desktop statistics page. */ export function StatsScreen({ tracked, locked, }: { tracked: SubjectStats[]; locked: { id: string; key: string }[]; }) { const { t, tOpt } = useApp(); const { doneCount, ready } = useProgress(); const totals = tracked.reduce( (acc, subject) => { const total = subject.lessons.reduce((a, l) => a + l.taskCount, 0); const done = subject.lessons.reduce((a, l) => a + doneCount(subject.id, l.id), 0); const finished = subject.lessons.filter( (l) => l.taskCount > 0 && doneCount(subject.id, l.id) >= l.taskCount ).length; return { done: acc.done + done, total: acc.total + total, finishedUnits: acc.finishedUnits + finished, openUnits: acc.openUnits + subject.lessons.length, }; }, { done: 0, total: 0, finishedUnits: 0, openUnits: 0 } ); const percent = totals.total ? Math.round((totals.done / totals.total) * 100) : 0; return (
{t('stats_sub')}