feat(manager): Part 2 — Online Orders page and sidebar integration

- connect_orders.py: add GET /api/connect/orders?status=active|history endpoints
- api/client.js: add getIncomingOrders, getActiveOrders, getOrderHistory,
  acceptOnlineOrder, rejectOnlineOrder, updateOnlineOrderStatus
- OnlineOrdersPage.jsx: three-tab page (Incoming / Active / History) with
  order cards, action buttons (accept/reject/status progression),
  20 s polling, SSE listener for online_order_received/updated events,
  and optimistic UI updates
- App.jsx: add /online-orders route
- Sidebar.jsx: add Online Orders nav item with red badge showing pending count,
  polling every 20 s independently of the page

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 09:59:21 +03:00
co-authored by Claude Sonnet 4.6
parent 37fb25c8c2
commit aed71a18d8
5 changed files with 478 additions and 12 deletions
+35 -12
View File
@@ -1,17 +1,33 @@
import { NavLink } from 'react-router-dom'
import { useState } from 'react'
import { BarChart2, LayoutGrid, ClipboardList, Package, Settings, ChevronRight, ChevronLeft } from 'lucide-react'
const NAV = [
{ to: '/dashboard', icon: BarChart2, label: 'Dashboard' },
{ to: '/tables', icon: LayoutGrid, label: 'Τραπέζια' },
{ to: '/reports', icon: ClipboardList, label: 'Αναφορές' },
{ to: '/management', icon: Package, label: 'Διαχείριση' },
{ to: '/settings', icon: Settings, label: 'Ρυθμίσεις' },
]
import { useState, useEffect, useRef } from 'react'
import { BarChart2, LayoutGrid, ClipboardList, Package, Settings, ChevronRight, ChevronLeft, ShoppingBag } from 'lucide-react'
import { getIncomingOrders } from '../api/client'
export default function Sidebar() {
const [collapsed, setCollapsed] = useState(false)
const [pendingCount, setPendingCount] = useState(0)
const pollRef = useRef(null)
useEffect(() => {
async function fetchPending() {
try {
const { data } = await getIncomingOrders()
setPendingCount(data.length)
} catch { /* silently ignore — sidebar badge is non-critical */ }
}
fetchPending()
pollRef.current = setInterval(fetchPending, 20_000)
return () => clearInterval(pollRef.current)
}, [])
const 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: '/settings', icon: Settings, label: 'Ρυθμίσεις' },
]
return (
<aside className={`flex flex-col bg-primary-800 text-white shrink-0 transition-all duration-200 ${collapsed ? 'w-16' : 'w-56'}`}>
@@ -28,7 +44,7 @@ export default function Sidebar() {
</div>
<nav className="flex-1 py-4 space-y-1 px-2">
{NAV.map(({ to, icon: Icon, label }) => (
{NAV.map(({ to, icon: Icon, label, badge }) => (
<NavLink
key={to}
to={to}
@@ -37,7 +53,14 @@ export default function Sidebar() {
(isActive ? 'bg-primary-600 text-white' : 'text-primary-100 hover:bg-primary-700')
}
>
<Icon size={20} className="shrink-0" />
<div className="relative shrink-0">
<Icon size={20} />
{badge > 0 && (
<span className="absolute -top-1.5 -right-1.5 bg-red-500 text-white text-[10px] font-bold w-4 h-4 rounded-full flex items-center justify-center leading-none">
{badge > 9 ? '9+' : badge}
</span>
)}
</div>
{!collapsed && <span className="text-sm">{label}</span>}
</NavLink>
))}