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:
@@ -63,6 +63,38 @@ async def _mirror_status_to_cloud(cloud_order_id: int, new_status: str, rejectio
|
||||
|
||||
# ── Endpoints ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@router.get("/orders", response_model=list[OrderOut])
|
||||
def get_orders_by_status(
|
||||
status: str,
|
||||
db: Session = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
"""
|
||||
?status=active → accepted | preparing | ready | out_for_delivery, newest first
|
||||
?status=history → delivered | rejected, newest first, limit 50
|
||||
"""
|
||||
if status == "active":
|
||||
statuses = ["accepted", "preparing", "ready", "out_for_delivery"]
|
||||
orders = (
|
||||
db.query(Order)
|
||||
.filter(Order.source == "online", Order.online_status.in_(statuses))
|
||||
.order_by(Order.opened_at.desc())
|
||||
.all()
|
||||
)
|
||||
elif status == "history":
|
||||
statuses = ["delivered", "rejected"]
|
||||
orders = (
|
||||
db.query(Order)
|
||||
.filter(Order.source == "online", Order.online_status.in_(statuses))
|
||||
.order_by(Order.opened_at.desc())
|
||||
.limit(50)
|
||||
.all()
|
||||
)
|
||||
else:
|
||||
raise HTTPException(status_code=400, detail=f"Unknown status filter '{status}'. Use 'active' or 'history'.")
|
||||
return orders
|
||||
|
||||
|
||||
@router.get("/orders/incoming", response_model=list[OrderOut])
|
||||
def get_incoming_orders(
|
||||
db: Session = Depends(get_db),
|
||||
|
||||
Reference in New Issue
Block a user