// Sidebar / Topbar layout shells const NAV_ITEMS = [ { id: 'home', label: 'Start', icon: 'home' }, { id: 'kombiniert', label: 'Ausgabe & Rückgabe', icon: 'refresh-cw' }, { id: 'verkauf', label: 'Buchausgabe', icon: 'cart' }, { id: 'rueckgabe', label: 'Buchrückgabe', icon: 'return' }, { id: 'schueler', label: 'Schüler', icon: 'users' }, { id: 'buecher', label: 'Bücher', icon: 'book' }, { id: 'lernmaterial', label: 'Lernmaterial', icon: 'package' }, { id: 'buchhaltung', label: 'Rechnungsversand & Buchhaltung', icon: 'euro' }, { id: 'klassenversetzung', label: 'Versetzung', icon: 'arrow-right' }, { id: 'archiv', label: 'Archiv', icon: 'archive' }, { id: 'profil', label: 'Einstellungen', icon: 'settings' }, ]; function useSchuljahr() { const [sj, setSj] = React.useState(null); React.useEffect(() => { window.api.einstellungen.get().then(e => { const raw = e.schuljahr_aktuell; if (!raw) return; const parts = raw.split('/'); const startYear = parts[0].trim(); const endYear = (parts[1] || '').trim(); setSj({ label: startYear + ' / ' + endYear, short: startYear + '/' + endYear.slice(-2), startDate: '01. Aug. ' + startYear, }); }).catch(console.error); }, []); return sj; } function Sidebar({ current, onNav, accent }) { const sjFromApi = useSchuljahr(); const now = new Date(); const y = now.getFullYear(); const fallbackYear = now.getMonth() < 7 ? y - 1 : y; const sjFallback = { label: fallbackYear + ' / ' + (fallbackYear + 1), short: fallbackYear + '/' + String(fallbackYear + 1).slice(-2), startDate: '01. Aug. ' + fallbackYear }; const sj = sjFromApi || sjFallback; return ( ); } function Topbar({ current, onNav, accent }) { const sjFromApi = useSchuljahr(); const now = new Date(); const y = now.getFullYear(); const fallbackYear = now.getMonth() < 7 ? y - 1 : y; const sjFallback = { label: fallbackYear + ' / ' + (fallbackYear + 1), short: fallbackYear + '/' + String(fallbackYear + 1).slice(-2), startDate: '01. Aug. ' + fallbackYear }; const sj = sjFromApi || sjFallback; return ( { e.target.style.display = 'none'; e.target.parentNode.innerHTML = ''; }} /> Bücherei {NAV_ITEMS.map(item => { const active = current === item.id; return ( onNav(item.id)} style={{ display: 'flex', alignItems: 'center', gap: 7, padding: '6px 11px', borderRadius: 7, background: active ? '#f1f5f9' : 'transparent', border: 'none', color: active ? '#0f172a' : '#64748b', fontSize: 13, fontWeight: active ? 500 : 450, cursor: 'pointer', fontFamily: 'inherit', }}> {item.label} {item.badge ? ( {item.badge} ) : null} ); })} Schuljahr {sj.short} AD window.dispatchEvent(new Event('unauthorized'))} style={{ display: 'flex', background: 'none', border: 'none', color: '#94a3b8', cursor: 'pointer', padding: 0 }} title="Abmelden"> ); } window.Sidebar = Sidebar; window.Topbar = Topbar; window.NAV_ITEMS = NAV_ITEMS;