import { NavLink } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { useAuth } from '../../context/AuthContext'; import { gdprApi } from '../../services/api'; import { LayoutDashboard, Users, FileText, LogOut, Settings, Code, Database, ClipboardList, MessageSquare, AlertCircle, Shield, FileCheck, UserCircle, Gauge, } from 'lucide-react'; export default function Sidebar() { const { user, logout, hasPermission, isCustomer, isCustomerPortal, developerMode } = useAuth(); // Prüfe ob Vollmachten vorhanden sind (nur für Portal-Kunden) const { data: authData } = useQuery({ queryKey: ['my-authorizations'], queryFn: () => gdprApi.getMyAuthorizations(), enabled: isCustomerPortal, staleTime: 60_000, }); const hasAuthorizations = (authData?.data?.length ?? 0) > 0; const navItems = [ { to: '/', icon: LayoutDashboard, label: 'Dashboard', show: true, end: true }, { to: '/my-profile', icon: UserCircle, label: 'Meine Daten', show: isCustomerPortal }, { to: '/customers', icon: Users, label: 'Kunden', show: hasPermission('customers:read') && !isCustomer }, { to: '/contracts', icon: FileText, label: 'Verträge', show: hasPermission('contracts:read'), end: true }, { to: '/contracts/cockpit', icon: AlertCircle, label: 'Vertrags-Cockpit', show: hasPermission('contracts:read') && !isCustomer }, { to: '/tasks', icon: isCustomer ? MessageSquare : ClipboardList, label: isCustomer ? 'Support-Anfragen' : 'Aufgaben', show: hasPermission('contracts:read') }, { to: '/my-meters', icon: Gauge, label: 'Zählerstände', show: isCustomerPortal }, { to: '/privacy', icon: Shield, label: 'Datenschutz', show: isCustomerPortal }, { to: '/authorizations', icon: FileCheck, label: 'Vollmachten', show: isCustomerPortal && hasAuthorizations }, ]; const developerItems = [ { to: '/developer/database', icon: Database, label: 'Datenbankstruktur' }, ]; return ( ); }