import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { apiGet } from "../lib/api"; import type { DashboardOverview } from "../lib/types"; interface AdminStats { totalSamples: number; openSamples: number; completedToday: number; nextSampleNumber: number; } export default function AdminDashboardPage() { const navigate = useNavigate(); const [stats, setStats] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { async function loadStats() { try { const dashboard = await apiGet("/dashboard"); setStats({ totalSamples: dashboard.nextSampleNumber - 1, openSamples: dashboard.openSamples, completedToday: dashboard.completedToday, nextSampleNumber: dashboard.nextSampleNumber, }); } finally { setLoading(false); } } void loadStats(); }, []); const adminModules = [ { title: "Landwirte", description: "Verwaltung der Landwirte und Betriebe", icon: "👨‍🌾", route: "/admin/landwirte", color: "#4a7c59", }, { title: "Benutzer", description: "Benutzerverwaltung und Berechtigungen", icon: "👥", route: "/admin/benutzer", color: "#5b7ba8", }, { title: "Medikamente", description: "Verwaltung der Medikamentenkataloge", icon: "💊", route: "/admin/medikamente", color: "#8b5a7c", }, { title: "Erreger", description: "Verwaltung der Erreger und Kürzel", icon: "🦠", route: "/admin/erreger", color: "#7c5a5a", }, { title: "Antibiogramm", description: "Verwaltung der Antibiotika-Kataloge", icon: "📊", route: "/admin/antibiogramm", color: "#5a7c7c", }, { title: "Berichtsvorlage", description: "Gestaltung der PDF-Berichtsvorlagen", icon: "📄", route: "/report-template", color: "#7c7c5a", }, ]; return (
{/* Header Bereich */}

Administration

Administrator Dashboard

Verwalten Sie Landwirte, Benutzer, Medikamente, Erreger und Systemeinstellungen.

{/* Statistik-Karten */}
Nächste Probennummer {loading ? "..." : stats?.nextSampleNumber}
Offene Proben {loading ? "..." : stats?.openSamples}
Heute abgeschlossen {loading ? "..." : stats?.completedToday}
Gesamtproben {loading ? "..." : stats?.totalSamples}
{/* Admin Module Grid */}

Verwaltung

Verwaltungsmodule

{adminModules.map((module) => ( ))}
{/* Schnellzugriffe */}

Schnellzugriff

Häufige Aktionen

); }