/** * Admin Dashboard page * Shows overview statistics and quick actions */ import { useEffect, useState } from 'react'; import { useAuth } from '@/stores/authStore'; import { getDashboardStats } from '@/lib/api/admin'; import type { DashboardStats } from '@/types/api/admin'; import { AdminLayout } from '@/components/features/admin/AdminLayout'; export function AdminDashboardPage() { const { token } = useAuth(); const [stats, setStats] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchStats = async () => { if (!token) return; try { setLoading(true); setError(null); const data = await getDashboardStats(token); setStats(data); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to load dashboard stats'); } finally { setLoading(false); } }; fetchStats(); }, [token]); if (loading) { return (

Loading dashboard...

); } if (error) { return (
{error}
); } return (

Dashboard

Overview of your DeutschLernen application

👥

Total Users

{stats?.totalUsers || 0}

📚

Total Lessons

{stats?.totalLessons || 0}

🎯

Total Quizzes

{stats?.totalQuizzes || 0}

📖

Story Segments

{stats?.totalStorySegments || 0}

✅

Active Users (Week)

{stats?.activeUsersThisWeek || 0}

📈

Avg. Progress

{stats ? stats.averageUserProgress.toFixed(1) + '%' : '0%'}

Quick Actions

About

This is the DeutschLernen admin panel. Here you can manage users, view progress reports, and generate story content for different CEFR levels.

Note: All actions in this panel require administrator privileges. Please ensure you are logged in as an admin user.

); }