'use client' import { useEffect, useState } from 'react' import { navigation, metaModules } from '@/lib/navigation' import { getStoredRole, isCategoryVisibleForRole, RoleId } from '@/lib/roles' import { CategoryCard } from '@/components/common/ModuleCard' import { InfoNote } from '@/components/common/InfoBox' import { ServiceStatus } from '@/components/common/ServiceStatus' import { NightModeWidget } from '@/components/dashboard/NightModeWidget' import Link from 'next/link' interface Stats { activeDocuments: number openDSR: number registeredUsers: number totalConsents: number gpuInstances: number } export default function DashboardPage() { const [stats, setStats] = useState({ activeDocuments: 0, openDSR: 0, registeredUsers: 0, totalConsents: 0, gpuInstances: 0, }) const [loading, setLoading] = useState(true) const [currentRole, setCurrentRole] = useState(null) useEffect(() => { const role = getStoredRole() setCurrentRole(role) // Load stats const loadStats = async () => { try { const response = await fetch('http://localhost:8081/api/v1/admin/stats') if (response.ok) { const data = await response.json() setStats({ activeDocuments: data.documents_count || 0, openDSR: data.open_dsr_count || 0, registeredUsers: data.users_count || 0, totalConsents: data.consents_count || 0, gpuInstances: 0, }) } } catch (error) { console.log('Stats not available') } finally { setLoading(false) } } loadStats() }, []) const statCards = [ { label: 'Aktive Dokumente', value: stats.activeDocuments, color: 'text-green-600' }, { label: 'Offene DSR', value: stats.openDSR, color: stats.openDSR > 0 ? 'text-orange-600' : 'text-slate-600' }, { label: 'Registrierte Nutzer', value: stats.registeredUsers, color: 'text-blue-600' }, { label: 'Zustimmungen', value: stats.totalConsents, color: 'text-purple-600' }, { label: 'GPU Instanzen', value: stats.gpuInstances, color: 'text-pink-600' }, ] const visibleCategories = currentRole ? navigation.filter(cat => isCategoryVisibleForRole(cat.id, currentRole)) : navigation return (
{/* Stats Grid */}
{statCards.map((stat) => (
{loading ? '-' : stat.value}
{stat.label}
))}
{/* Categories */}

Bereiche

{visibleCategories.map((category) => ( ))}
{/* Quick Links */}

Schnellzugriff

{metaModules.filter(m => m.id !== 'dashboard').map((module) => (
{module.id === 'onboarding' && '📖'} {module.id === 'backlog' && '📋'} {module.id === 'rbac' && '👥'}

{module.name}

{module.description}

))}
{/* Infrastructure & System Status */}

Infrastruktur

{/* Night Mode Widget */} {/* System Status */}
{/* Recent Activity */}

Aktivitaet

{/* Recent DSR */}

Neueste Datenschutzanfragen

Alle anzeigen

Keine offenen Anfragen

{/* Info Box */}

Dieses neue Admin-Frontend bietet eine verbesserte Navigation mit Kategorien und Rollen-basiertem Zugriff. Das alte Admin-Frontend ist weiterhin unter Port 3000 verfuegbar.

) }