feat(terminal): the customer display, with an idle screen each venue designs

Plan step 3.4. Owner (2026-11-16): the idle screen is configurable per venue.
- routers/customer_display.py (module customer_display, /api/display): the counter POS
  pushes its state (POST /api/display/state: idle | cart | paid with lines, total, paid,
  change); only the displays linked to that POS get `display.state`; the last state is kept
  in memory for a display that reconnects (GET /api/display/state). pos_counter's device
  scope includes customer_display.state.
- The idle screen: setting customer_display.idle (name, logo, logo + name, blank, one
  image, slideshow, QR code to the online ordering / QR menu / any link; a line of text;
  dark or light); images uploaded to /app/data/display_media (JPG/PNG/WebP/GIF ≤ 5 MB,
  random names, served publicly on the LAN); a change sends `display.settings` to every
  display. New key customer_display.manage (owners, store managers; migration 0022).
- Terminal: CustomerDisplayApp (cart with a large total, "Thank you" with the change for
  12 s, the venue's idle screen, its theme), logic.js (unit-tested); the POS pushes from the
  sale cart and the payment dialog (tables, online orders too) via useDisplay().
  qrcode.react added to the terminal (already in the workspace).
- Manager: Settings → Customer display (style cards, venue name, text, look, slide seconds,
  QR target/link/caption, image upload/pick/order/delete).
- Tests: tests/test_customer_display.py (3), terminal display.test.mjs (3); e2e terminal
  (linked vs unlinked display, < 1 s, paid, QR and slideshow idle screens), manager (the
  settings tab).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 08:34:05 +02:00
co-authored by Claude Opus 5.5
parent 18d580d87c
commit 88a9703902
27 changed files with 1073 additions and 25 deletions
+16
View File
@@ -2,6 +2,7 @@
// the menu, the cart priced by the backend, the tables, a table's order, online orders and receipts. Kept fresh by the
// live connection, so a waiter's phone and the counter see each other's changes at once.
import { useCallback, useEffect, useRef, useState } from 'react'
import { useModule } from '@xenia/access'
import client from '../../api/client'
import { useLiveEvent, useLiveEvents } from '../../device/context'
@@ -130,6 +131,21 @@ export function useOnline(enabled) {
return { data, reload: load }
}
// The customer display (plan step 3.4): what this counter's customer should see. One timer for
// the whole screen, so the last thing said wins; "paid" goes at once, the rest after a moment
// (a burst of cart changes is one message). Nothing is sent while the module is off.
let displayTimer = null
/** push({ mode: 'idle' | 'cart' | 'paid', lines?, total?, paid?, change? }) → POST /api/display/state. */
export function useDisplay() {
const on = useModule('customer_display')
return useCallback(state => {
if (!on) return
clearTimeout(displayTimer)
displayTimer = setTimeout(() => { client.post('/api/display/state', state, quiet).catch(() => {}) }, state.mode === 'paid' ? 0 : 200)
}, [on])
}
const BOOKING_EVENTS = ['reservation_requested', 'reservation_updated']
/** GET /api/connect/bookings: { requested, upcoming } (null while loading); live (S.6). */