diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 09f4db8..24aee32 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -16,10 +16,27 @@ import { IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand, IconExternalLink, + IconMessages, } from '@tabler/icons-react' import { openProjectAdmin } from '../lib/employeeAdminApi' import { serverpulsApi } from '../lib/serverpulsApi' import { startsCollapsed } from '../lib/sidebar' +import { buildNavLinks } from '../lib/navLinks' +import { useChatUnread } from '../hooks/useChatUnread' + +const ICONS = { + tickets: , + planboard: , + projects: , + services: , + customers: , + chat: , + leads: , + finance: , + legal: , + serverpuls: , + admin: , +} export default function Sidebar() { const { user, logout, isAdmin } = useAuth() @@ -28,6 +45,7 @@ export default function Sidebar() { const [collapsed, setCollapsed] = useState(() => startsCollapsed()) const [switching, setSwitching] = useState(false) const [pulseLevel, setPulseLevel] = useState('ok') + const chatUnread = useChatUnread() // Serverpuls-Punkt: nur Admins, beim Laden und alle 5 Minuten; Fehler bleiben still useEffect(() => { @@ -53,20 +71,8 @@ export default function Sidebar() { navigate('/login') } - // Eine flache Liste: fuer ein kleines Team reichen acht Eintraege ohne Gruppen - const links = [ - { label: 'Tickets', href: '/tickets', icon: }, - { label: 'Planboard', href: '/planboard', icon: }, - { label: 'Projekte', href: '/projects', icon: }, - { label: 'Services', href: '/services', icon: }, - { label: 'Kunden', href: '/customers', icon: }, - // Leads liegen auf Eis (Lead-Automatik gestoppt 2026-09-30): grau, nicht klickbar - { label: 'Leads', href: '/leads', icon: , paused: true }, - ...(isAdmin ? [{ label: 'Finanzen', href: '/finance', also: '/finanzen', icon: }] : []), - { label: 'Rechtliches', href: '/rechtliches', icon: }, - ...(isAdmin ? [{ label: 'Serverpuls', href: '/serverpuls', icon: , dot: pulseLevel }] : []), - ...(isAdmin ? [{ label: 'Admin', href: '/admin', icon: }] : []), - ] + // Eintraege und Unterpunkte (Kunden -> Chat) aus lib/navLinks.js, Icons ueber key + const links = buildNavLinks({ isAdmin, pulseLevel, chatUnread }) const isActive = (href) => location.pathname === href || location.pathname.startsWith(href + '/') @@ -92,7 +98,7 @@ export default function Sidebar() { title={`${link.label} (pausiert)`} aria-disabled="true" > - {link.icon} + {ICONS[link.key]} {link.label} ) : ( @@ -102,7 +108,7 @@ export default function Sidebar() { className={`side-link ${isLinkActive(link) ? 'active' : ''}`} title={link.label} > - {link.icon} + {ICONS[link.key]} {link.label} {link.dot && link.dot !== 'ok' && ( )} - ))} + )).flatMap((item, i) => [ + item, + ...(links[i].children || []).map((child) => ( + 0 ? `${child.label} (${child.count} ungelesen)` : child.label} + > + {ICONS[child.key]} + {child.label} + {child.count > 0 && {child.count}} + + )), + ])}