// Bellia — Shell : Sidebar + Header globaux const MODULES = [ { id: 'dashboard', label: 'Tableau de bord', icon: 'dashboard' }, { id: 'ventes', label: 'Ventes', icon: 'bag' }, { id: 'depenses', label: 'Dépenses', icon: 'receipt' }, { id: 'rh', label: 'Ressources humaines', icon: 'users' }, { id: 'achats', label: 'Achats', icon: 'package' }, { id: 'ref', label: 'Référentiel', icon: 'book' }, { id: 'analyse', label: 'Analyse', icon: 'chart' }, { id: 'admin', label: 'Administration', icon: 'shield' }, { id: 'automation',label: 'Automatisation', icon: 'zap' }, { id: 'simulateur',label: 'Simulateur', icon: 'calc' }, ]; const RESTAURANTS = [ { id: 'rep', name: 'Cantine Corner — République', initials: 'CR', city: 'Paris 11e' }, { id: 'bat', name: 'Cantine Corner — Bastille', initials: 'CB', city: 'Paris 12e' }, { id: 'mtg', name: 'Cantine Corner — Montrouge', initials: 'CM', city: 'Hauts-de-Seine' }, ]; const RestoSwitcher = ({ onOpenSettings }) => { const [open, setOpen] = React.useState(false); const [sel, setSel] = React.useState(() => { try { const s = JSON.parse(localStorage.getItem('bellia-restos') || 'null'); return s || ['rep']; } catch { return ['rep']; } }); const ref = React.useRef(null); React.useEffect(() => { try { localStorage.setItem('bellia-restos', JSON.stringify(sel)); } catch {} }, [sel]); React.useEffect(() => { const h = (e) => { if (ref.current && !ref.current.contains(e.target)) setOpen(false); }; document.addEventListener('mousedown', h); return () => document.removeEventListener('mousedown', h); }, []); const toggle = (id) => setSel(s => s.includes(id) ? (s.length > 1 ? s.filter(x => x !== id) : s) : [...s, id]); const all = () => setSel(RESTAURANTS.map(r => r.id)); const label = sel.length === RESTAURANTS.length ? 'Tous les restaurants' : sel.length === 1 ? RESTAURANTS.find(r => r.id === sel[0])?.name.replace('Cantine Corner — ', '') : `${sel.length} restaurants sélectionnés`; const initials = sel.length === RESTAURANTS.length ? 'CC' : sel.length === 1 ? RESTAURANTS.find(r => r.id === sel[0]).initials : `${sel.length}`; return (
{open && (
SÉLECTION MULTI
{RESTAURANTS.map(r => { const checked = sel.includes(r.id); return ( ); })}
)}
); }; const Sidebar = ({ current, onNav }) => ( ); const Header = ({ title, subtitle, right }) => { const [narrow, setNarrow] = React.useState(false); React.useEffect(() => { const check = () => setNarrow(window.innerWidth < 1180); check(); window.addEventListener('resize', check); return () => window.removeEventListener('resize', check); }, []); return (

{title}

{subtitle &&
{subtitle}
}
{narrow ? ( ) : (
⌘K
)} {right}
); }; const PeriodPicker = ({ value = 'mois', onChange = () => {} }) => { const items = [{ id: 'jour', l: 'Jour' }, { id: 'sem', l: 'Semaine' }, { id: 'mois', l: 'Mois' }, { id: 'an', l: 'Année' }]; return (
{items.map(i => { const active = value === i.id; return ( ); })}
); }; const PageShell = ({ current, onNav, children }) => (
{children}
); Object.assign(window, { Sidebar, Header, PeriodPicker, PageShell, MODULES, RESTAURANTS });