feat(waiter): table bookings on the phone; shared ReasonPicker (platform-v2 step 4.8c)
- Waiter: Bookings (side drawer, for whoever has connect_orders.manage or reservations.manage, with the online-orders app on): requests made online are confirmed or declined with a reason the guest sees; confirmed ones are seated at a free table (its seats shown, a warning mark when the party is bigger) or cancelled / marked as a no-show; the food ordered ahead and its kitchen time; live updates. - Backend: the bookings routes take reservations.manage too (require_any). - @xenia/ui ReasonPicker + reasonText (gallery, unit test), first piece moved from the terminal (4.6 → 4.8): the counter's online reject and booking decline dialogs use it; the waiter loads @xenia/ui styles.css (the .x-* components; tokens as before). - Tests: waiter e2e +2 (request listed with the key, confirmed and seated from the phone); terminal.mjs and qr_table.mjs green. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,7 @@ from pydantic import BaseModel, Field
|
||||
from sqlalchemy.orm import Session, selectinload
|
||||
|
||||
from config import settings
|
||||
from core.access.deps import require
|
||||
from core.access.deps import require, require_any
|
||||
from core.errors import XeniaError
|
||||
from core.timeutil import utcnow
|
||||
from database import get_db
|
||||
@@ -304,8 +304,13 @@ def _booking_changed(background: BackgroundTasks, r) -> None:
|
||||
broadcast_sync("reservation_updated", {"reservation_id": r.id, "status": r.status})
|
||||
|
||||
|
||||
# Bookings: the counter and, since 4.8, the waiters' phones; whoever handles online orders or
|
||||
# manages reservations
|
||||
_BOOKINGS = require_any("reservations.manage", MANAGE) # the last refusal is the one reported
|
||||
|
||||
|
||||
@router.get("/bookings")
|
||||
def list_bookings(db: Session = Depends(get_db), user=Depends(require(MANAGE))):
|
||||
def list_bookings(db: Session = Depends(get_db), user=Depends(_BOOKINGS)):
|
||||
"""The counter's bookings: `requested` (online, waiting for an answer, soonest first) and
|
||||
`upcoming` (confirmed, from 4 hours ago on, soonest first; any source)."""
|
||||
from datetime import timedelta
|
||||
@@ -319,7 +324,7 @@ def list_bookings(db: Session = Depends(get_db), user=Depends(require(MANAGE))):
|
||||
|
||||
@router.post("/bookings/{reservation_id}/confirm")
|
||||
def confirm_booking(reservation_id: int, background: BackgroundTasks, db: Session = Depends(get_db),
|
||||
user=Depends(require(MANAGE))):
|
||||
user=Depends(_BOOKINGS)):
|
||||
"""Confirm: the customer is told; food ordered ahead goes to the kitchen at its fire time
|
||||
(at once if that time has passed and the day is open)."""
|
||||
from routers import orders as orders_api
|
||||
@@ -338,7 +343,7 @@ def confirm_booking(reservation_id: int, background: BackgroundTasks, db: Sessio
|
||||
|
||||
@router.post("/bookings/{reservation_id}/decline")
|
||||
def decline_booking(reservation_id: int, body: BookingAnswer, background: BackgroundTasks,
|
||||
db: Session = Depends(get_db), user=Depends(require(MANAGE))):
|
||||
db: Session = Depends(get_db), user=Depends(_BOOKINGS)):
|
||||
from services import online_reservations as svc
|
||||
r = _booking(db, reservation_id)
|
||||
svc.decline(db, r, body.reason)
|
||||
@@ -349,7 +354,7 @@ def decline_booking(reservation_id: int, body: BookingAnswer, background: Backgr
|
||||
|
||||
@router.post("/bookings/{reservation_id}/arrive")
|
||||
def arrive_booking(reservation_id: int, body: ArriveRequest, background: BackgroundTasks,
|
||||
db: Session = Depends(get_db), user=Depends(require(MANAGE))):
|
||||
db: Session = Depends(get_db), user=Depends(_BOOKINGS)):
|
||||
"""The guests are here: seat them (optional table); their food's order moves to the table
|
||||
(and goes to the kitchen now if it hadn't yet)."""
|
||||
from services import online_reservations as svc
|
||||
@@ -367,7 +372,7 @@ def arrive_booking(reservation_id: int, body: ArriveRequest, background: Backgro
|
||||
|
||||
@router.post("/bookings/{reservation_id}/cancel")
|
||||
def cancel_booking(reservation_id: int, body: CancelRequest, background: BackgroundTasks,
|
||||
db: Session = Depends(get_db), user=Depends(require(MANAGE))):
|
||||
db: Session = Depends(get_db), user=Depends(_BOOKINGS)):
|
||||
from services import online_reservations as svc
|
||||
r = _booking(db, reservation_id)
|
||||
svc.cancel(db, r, body.status, body.reason)
|
||||
|
||||
Reference in New Issue
Block a user