diff --git a/manager_dashboard/src/components/Sidebar.jsx b/manager_dashboard/src/components/Sidebar.jsx index 4096429..9a5ef0b 100644 --- a/manager_dashboard/src/components/Sidebar.jsx +++ b/manager_dashboard/src/components/Sidebar.jsx @@ -2,10 +2,15 @@ import { NavLink } from 'react-router-dom' import { useState, useEffect, useRef } from 'react' import { BarChart2, LayoutGrid, ClipboardList, Package, Settings, ChevronRight, ChevronLeft, ShoppingBag, NotebookPen, Receipt, BookUser, Users, CreditCard, Trash2, ChefHat, CalendarDays } from 'lucide-react' import { getIncomingOrders } from '../api/client' +import { isFeatureEnabled } from '../hooks/usePhase2Features' + +// Phase 2 feature IDs mapped to their sidebar routes (must match usePhase2Features defs) +const PHASE2_ROUTES = new Set(['/notes', '/expenses', '/contacts', '/customers', '/tabs', '/waste', '/kds', '/schedule']) export default function Sidebar() { const [collapsed, setCollapsed] = useState(false) const [pendingCount, setPendingCount] = useState(0) + const [, featTick] = useState(0) const pollRef = useRef(null) useEffect(() => { @@ -20,23 +25,37 @@ export default function Sidebar() { return () => clearInterval(pollRef.current) }, []) - const NAV = [ + // Re-render when feature flags change + useEffect(() => { + const handler = () => featTick(n => n + 1) + window.addEventListener('phase2features', handler) + window.addEventListener('storage', handler) + return () => { + window.removeEventListener('phase2features', handler) + window.removeEventListener('storage', handler) + } + }, []) + + const ALL_NAV = [ { to: '/dashboard', icon: BarChart2, label: 'Dashboard' }, { to: '/tables', icon: LayoutGrid, label: 'Τραπέζια' }, { to: '/online-orders', icon: ShoppingBag, label: 'Online Orders', badge: pendingCount }, { to: '/reports', icon: ClipboardList, label: 'Αναφορές' }, { to: '/management', icon: Package, label: 'Διαχείριση' }, - { to: '/notes', icon: NotebookPen, label: 'Σημειώσεις' }, - { to: '/expenses', icon: Receipt, label: 'Έξοδα' }, - { to: '/contacts', icon: BookUser, label: 'Επαφές' }, - { to: '/customers', icon: Users, label: 'Πελάτες' }, - { to: '/tabs', icon: CreditCard, label: 'Καρτέλες' }, - { to: '/waste', icon: Trash2, label: 'Αποβλήτα' }, - { to: '/kds', icon: ChefHat, label: 'KDS' }, - { to: '/schedule', icon: CalendarDays, label: 'Πρόγραμμα' }, + { to: '/notes', icon: NotebookPen, label: 'Σημειώσεις', phase2: 'notes' }, + { to: '/expenses', icon: Receipt, label: 'Έξοδα', phase2: 'expenses' }, + { to: '/contacts', icon: BookUser, label: 'Επαφές', phase2: 'contacts' }, + { to: '/customers', icon: Users, label: 'Πελάτες', phase2: 'customers' }, + { to: '/tabs', icon: CreditCard, label: 'Καρτέλες', phase2: 'tabs' }, + { to: '/waste', icon: Trash2, label: 'Αποβλήτα', phase2: 'waste' }, + { to: '/kds', icon: ChefHat, label: 'KDS', phase2: 'kds' }, + { to: '/schedule', icon: CalendarDays, label: 'Πρόγραμμα', phase2: 'schedule' }, { to: '/settings', icon: Settings, label: 'Ρυθμίσεις' }, ] + // Filter out disabled Phase 2 entries + const NAV = ALL_NAV.filter(item => !item.phase2 || isFeatureEnabled(item.phase2)) + return (