feat: tables and orders in the manager on v2 (platform-v2 step 6.9)

- manager: new pages/orders/ (Tables page cards + quick actions, order page with
  lines, multi-select pay/discount/cancel/tab, staff + customer, price changes,
  history, the menu + cart beside it); a free table opens a new order on first
  Send; v1 TablesPage, OrderDetailPage, DesktopOrderingTab, ManagerOrderDrawer
  and PaymentMethodModal removed
- ordering by line id like the phones: GET /api/orders/menu (the counter's
  product shape, in-store prices); the product dialog, cart rules and quote hook
  move to packages/ordering (@xenia/ordering), shared by counter, menu tablet,
  manager
- close follows orders.close_with_unpaid (pay first, or write off after saying
  so) on the order page and the overview's quick view; paying asks cash or card
- a confirmed booking can keep its table ahead (manager, phones, counter):
  POST /api/connect/bookings/{id}/table, reservations create/PATCH; refused with
  reservation.table_kept within 2 h of another booking
- tests: test_manager_ordering.py, online bookings +2, manager orders.test.mjs,
  @xenia/ordering, e2e manager.mjs (take, change, pay-first close, RESERVED)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 21:58:46 +02:00
co-authored by Claude Opus 5.5
parent f4aae6abbc
commit 070c9cf625
56 changed files with 2339 additions and 3846 deletions
+15 -5
View File
@@ -30,7 +30,8 @@ export default function BookingsPage() {
try {
const [tables, orders] = await Promise.all([db.pos_tables.toArray(), db.pos_orders.toArray()])
const busyTables = new Set(orders.filter(o => OPEN.includes(o.status)).map(o => o.table_id))
setFree(tables.filter(tb => tb.is_active !== false && !busyTables.has(tb.id)))
// 6.9: every table (a booking can keep one that is busy now); busy ones say so
setFree(tables.filter(tb => tb.is_active !== false).map(tb => ({ ...tb, busy: busyTables.has(tb.id) })))
} catch { setFree([]) }
}, [t])
@@ -82,7 +83,8 @@ export default function BookingsPage() {
{upcoming.length === 0 && <p style={empty}>{t('bookings.noUpcoming')}</p>}
{upcoming.map(b => (
<BookingCard key={b.id} booking={b}>
<SeatControls booking={b} free={free} busy={busy === b.id} onSeat={tableId => run(b, 'arrive', { table_id: tableId })}
<SeatControls key={`${b.id}-${b.table_id ?? ''}`} booking={b} free={free} busy={busy === b.id} onSeat={tableId => run(b, 'arrive', { table_id: tableId })}
onKeep={tableId => run(b, 'table', { table_id: tableId })}
onCancel={status => run(b, 'cancel', { status })} />
</BookingCard>
))}
@@ -130,10 +132,11 @@ function BookingCard({ booking: b, children }) {
)
}
function SeatControls({ booking, free, busy, onSeat, onCancel }) {
function SeatControls({ booking, free, busy, onSeat, onKeep, onCancel }) {
const { t } = useTranslation('waiter')
const [table, setTable] = useState('')
const options = free.map(tb => ({ id: tb.id, name: tb.label || `T${tb.number}`, seats: tb.seat_count }))
const [table, setTable] = useState(booking.table_id ? String(booking.table_id) : '')
const options = free.map(tb => ({ id: tb.id, name: tb.label || `T${tb.number}`, seats: tb.seat_count, busy: tb.busy }))
const kept = booking.table_id ? String(booking.table_id) : ''
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<select value={table} onChange={e => setTable(e.target.value)} aria-label={t('bookings.table')} data-testid="booking-table"
@@ -143,9 +146,16 @@ function SeatControls({ booking, free, busy, onSeat, onCancel }) {
<option key={o.id} value={o.id}>
{o.name}{o.seats ? ` · ${t('seats.table', { count: o.seats })}` : ''}
{o.seats && booking.party_size > o.seats ? ' ⚠' : ''}
{o.busy ? ` · ${t('bookings.busyNow')}` : ''}
</option>
))}
</select>
{/* 6.9: keep the table ahead, so it shows RESERVED and others see it's taken */}
{table !== kept && (
<button className="btn btn--secondary" disabled={busy} onClick={() => onKeep(table ? Number(table) : null)} data-testid="booking-keep">
{table ? t('bookings.keep') : t('bookings.release')}
</button>
)}
<button className="btn btn--accent" disabled={busy} onClick={() => onSeat(table ? Number(table) : null)} data-testid="booking-arrive">
{t('bookings.arrive')}
</button>