feat(manager): the overview, online orders and the day summary on v2 (platform-v2 step 6.2)

- DashboardPage (2.8k lines) → src/pages/overview/: OverviewPage + cards (shifts, tables,
  pending prints, notes, bookings, messages) and dialogs (order at a glance, shift review /
  end with the cash handover, day summary with cash count and checks); arithmetic in
  overviewLogic.js (tests/overview.test.mjs). Data via useLiveQuery: orders and tables
  live, day and shifts every 15 s. Bookings typed in venue time; decline reason in a dialog.
- OnlineOrdersPage → src/pages/online/ on react-query + live events; unused API helpers dropped.
- WorkdaySummaryModal → overview/DaySummaryDialog + DaySummaryTabs.
- Every text in manager.json (en + el, 342 keys); tokens only; v2.json adds overview, hooks.
- Backend: business day open/close answer only with codes (license.locked, license.expired,
  business_day.orders_open); XeniaError's v1 `detail` removed.
- @xenia/i18n: formatDateTime with Intl options threw "unknown date style" (fixed, tested).
- e2e manager.mjs: open the day, a shift (start, stats, end short), a live table, a booking,
  day stats, Greek, close the day (forced), online orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 09:01:51 +02:00
co-authored by Claude Opus 5.5
parent 2dc5da446e
commit 8a02173450
32 changed files with 3161 additions and 4126 deletions
+2 -3
View File
@@ -263,13 +263,12 @@ CODES: dict[str, tuple[int, str]] = {
class XeniaError(Exception):
"""An API error with a registered code. raise XeniaError("order.not_found", order_id=5)."""
def __init__(self, code: str, status: int | None = None, *, detail=None, **params):
def __init__(self, code: str, status: int | None = None, **params):
if code not in CODES:
raise KeyError(f"unregistered error code {code!r}: add it to core/errors.py CODES")
default_status, template = CODES[code]
self.code = code
self.status = status or default_status
self.detail = detail # v1-shaped `detail` some old pages still read (6.x removes)
self.params = params
try:
self.message = template.format(**params)
@@ -284,7 +283,7 @@ def error_body(code: str, message: str, params: dict | None = None, detail=None)
async def _xenia_error_handler(request: Request, exc: XeniaError):
return JSONResponse(error_body(exc.code, exc.message, exc.params, detail=exc.detail), status_code=exc.status)
return JSONResponse(error_body(exc.code, exc.message, exc.params), status_code=exc.status)
async def _http_exception_handler(request: Request, exc: StarletteHTTPException):
+3 -15
View File
@@ -49,19 +49,11 @@ def open_business_day(
# Gate: admin lock (already enforced or pending)
if license_state.get("locked") or license_state.get("lock_pending"):
raise XeniaError("license.locked", detail={
"code": "SYSTEM_LOCKED",
"message": "Το σύστημα έχει κλειδωθεί από διαχειριστή. Επικοινωνήστε με την υποστήριξη.",
})
raise XeniaError("license.locked")
# Gate: license expired and expiry grace period also over
if not license_state.get("licensed", True):
expires_at = license_state.get("expires_at", "")
raise XeniaError("license.expired", detail={
"code": "LICENSE_EXPIRED",
"message": "Η άδεια χρήσης έχει λήξει. Ανανεώστε την άδεια ή επικοινωνήστε με την υποστήριξη.",
"expires_at": expires_at,
})
raise XeniaError("license.expired")
opened_at = utcnow()
day = BusinessDay(opened_by_id=user.id, notes=body.notes,
@@ -97,11 +89,7 @@ def close_business_day(
OrderItem.status == "active",
).first() is not None
)
raise XeniaError("business_day.orders_open", detail={
"message": f"{len(open_orders)} table(s) still open, {with_pending} with unpaid items.",
"open_orders": len(open_orders),
"partially_paid": with_pending,
}, open_orders=len(open_orders), partially_paid=with_pending)
raise XeniaError("business_day.orders_open", open_orders=len(open_orders), partially_paid=with_pending)
now = utcnow()
-14
View File
@@ -110,17 +110,3 @@ def test_backend_code_raises_codes_not_http_exceptions():
for n, line in enumerate(p.read_text(encoding="utf-8").splitlines(), 1)
if re.search(r"\bHTTPException\s*\(", line)]
assert found == [], "use XeniaError (core/errors.py) instead: " + ", ".join(found)
def test_a_code_can_keep_a_v1_shaped_detail():
app = FastAPI()
install_error_handlers(app)
@app.get("/x")
def x():
raise XeniaError("business_day.orders_open", open_orders=2, partially_paid=1,
detail={"message": "2 tables open", "open_orders": 2, "partially_paid": 1})
body = TestClient(app).get("/x").json()
assert body["error"]["code"] == "business_day.orders_open" and body["error"]["params"] == {"open_orders": 2, "partially_paid": 1}
assert body["detail"]["open_orders"] == 2