diff --git a/packages/ui/src/components.css b/packages/ui/src/components.css
index b4cd78a..035f79e 100644
--- a/packages/ui/src/components.css
+++ b/packages/ui/src/components.css
@@ -315,3 +315,16 @@
.x-switch-row__label { display: block; font-size: var(--x-text-body); line-height: var(--x-leading-body); font-weight: var(--x-weight-medium); color: var(--x-ink); cursor: pointer; }
.x-switch-row__description { margin-top: var(--x-space-0-5); font-size: var(--x-text-label); line-height: var(--x-leading-label); color: var(--x-ink-2); }
.x-switch-row--disabled .x-switch-row__label { cursor: not-allowed; opacity: 0.6; }
+
+/* ── ReasonPicker ───────────────────────────────────────────────────────────── */
+.x-reasons { display: grid; gap: var(--x-space-2); }
+.x-reasons__list { display: grid; gap: var(--x-space-1); }
+.x-reasons__option {
+ min-height: var(--x-control-md); padding: 0 var(--x-space-3);
+ border: 0; border-radius: var(--x-radius-control); text-align: left;
+ font: inherit; font-size: var(--x-text-body); color: var(--x-ink); background: var(--x-surface-2);
+ cursor: pointer; transition: background-color var(--x-duration-fast) var(--x-ease);
+}
+.x-reasons__option:hover { background: var(--x-surface-3); }
+.x-reasons__option:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
+.x-reasons__option--on, .x-reasons__option--on:hover { background: var(--x-accent); color: var(--x-accent-fg); }
diff --git a/packages/ui/src/components/ReasonPicker.jsx b/packages/ui/src/components/ReasonPicker.jsx
new file mode 100644
index 0000000..2bb7de4
--- /dev/null
+++ b/packages/ui/src/components/ReasonPicker.jsx
@@ -0,0 +1,33 @@
+import { cx } from '../internal/cx.js'
+
+export { reasonText } from './reasons.js'
+
+/**
+ * Pick why (a booking declined, an online order rejected…): one of the given reasons or
+ * "other" with free text (plan step 4.8; first shared by the counter and the waiter's phone).
+ *
+ * `value` is the chosen option's value or 'other'. The reason to send:
+ * reasonText(value, options, other)
+ */
+export function ReasonPicker({ options, value, onChange, other = '', onOther, otherLabel = 'Other', ariaLabel, testIdPrefix = 'reason', className }) {
+ const all = [...options, { value: 'other', label: otherLabel }]
+ return (
+
+
+ {all.map(o => (
+
+ ))}
+
+ {value === 'other' && (
+
onOther?.(e.target.value)} data-testid={`${testIdPrefix}-other-text`} />
+ )}
+
+ )
+}
+
diff --git a/packages/ui/src/components/reasons.js b/packages/ui/src/components/reasons.js
new file mode 100644
index 0000000..747335f
--- /dev/null
+++ b/packages/ui/src/components/reasons.js
@@ -0,0 +1,7 @@
+/** The text to send for a ReasonPicker choice: the option's label, the typed text for 'other',
+ * '' for no choice. Plain JS so Node tests can import it. */
+export function reasonText(value, options, other = '') {
+ if (!value) return ''
+ if (value === 'other') return other.trim()
+ return options.find(o => o.value === value)?.label ?? ''
+}
diff --git a/packages/ui/src/index.js b/packages/ui/src/index.js
index 98bbaab..fb97005 100644
--- a/packages/ui/src/index.js
+++ b/packages/ui/src/index.js
@@ -21,6 +21,7 @@ export { Spinner } from './components/Spinner.jsx'
export { Field, Input, Textarea, Select } from './components/Field.jsx'
export { Switch } from './components/Switch.jsx'
export { Stepper } from './components/Stepper.jsx'
+export { ReasonPicker, reasonText } from './components/ReasonPicker.jsx'
export { UiLabelsProvider, DEFAULT_LABELS } from './components/labels.js'
export { cx } from './internal/cx.js'
export { THEMES, THEME_STORAGE_KEY, applyTheme, getStoredTheme } from './theme.js'
diff --git a/packages/ui/tests/reasons.test.mjs b/packages/ui/tests/reasons.test.mjs
new file mode 100644
index 0000000..b76cdc0
--- /dev/null
+++ b/packages/ui/tests/reasons.test.mjs
@@ -0,0 +1,10 @@
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { reasonText } from '../src/components/reasons.js'
+
+test('reasonText: the option label, the typed text for other, nothing for no choice', () => {
+ const options = [{ value: 'full', label: 'We are full' }]
+ assert.equal(reasonText('full', options), 'We are full')
+ assert.equal(reasonText('other', options, ' Private party '), 'Private party')
+ assert.equal(reasonText(null, options), '')
+})
diff --git a/terminal/src/apps/pos/BookingPanel.jsx b/terminal/src/apps/pos/BookingPanel.jsx
index 4e4b99d..e1f8f4f 100644
--- a/terminal/src/apps/pos/BookingPanel.jsx
+++ b/terminal/src/apps/pos/BookingPanel.jsx
@@ -7,7 +7,7 @@ import { useState } from 'react'
import { AlertTriangle, Ban, Check, ChefHat, MessageSquare, Phone, UserX, Users } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
-import { Button, Dialog, EmptyState, Input, Select } from '@xenia/ui'
+import { Button, Dialog, EmptyState, ReasonPicker, Select, reasonText } from '@xenia/ui'
import client from '../../api/client'
import { bookingSteps, foodState, freeTables, whenLabel } from './logic/bookings'
@@ -129,7 +129,8 @@ function DeclineDialog({ busy, error, onClose, onDecline }) {
const { t } = useTranslation('terminal')
const [choice, setChoice] = useState(null)
const [other, setOther] = useState('')
- const reason = choice === 'other' ? other.trim() : choice ? t(`pos.bookings.reasons.${choice}`) : ''
+ const options = REASONS.map(r => ({ value: r, label: t(`pos.bookings.reasons.${r}`) }))
+ const reason = reasonText(choice, options, other)
return (
diff --git a/terminal/src/apps/pos/OnlinePanel.jsx b/terminal/src/apps/pos/OnlinePanel.jsx
index ff99c41..c911b9b 100644
--- a/terminal/src/apps/pos/OnlinePanel.jsx
+++ b/terminal/src/apps/pos/OnlinePanel.jsx
@@ -11,7 +11,7 @@ import { useState } from 'react'
import { AlertTriangle, Ban, Banknote, Bike, Check, ChefHat, Clock, MapPin, MessageSquare, PackageCheck, Phone, ShoppingBag, Utensils } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
-import { Button, Dialog, EmptyState, Input } from '@xenia/ui'
+import { Button, Dialog, EmptyState, ReasonPicker, reasonText } from '@xenia/ui'
import client from '../../api/client'
import { diffRows, finishWord as finishOf, kindOf, nextStep } from './logic/online'
import { itemPayments, orderLines, orderSums, qtyLabel } from './logic/tables'
@@ -190,7 +190,8 @@ function RejectDialog({ busy, error, onClose, onReject }) {
const { t } = useTranslation('terminal')
const [choice, setChoice] = useState(null)
const [other, setOther] = useState('')
- const reason = choice === 'other' ? other.trim() : choice ? t(`pos.online.reasons.${choice}`) : ''
+ const options = REASONS.map(r => ({ value: r, label: t(`pos.online.reasons.${r}`) }))
+ const reason = reasonText(choice, options, other)
return (
diff --git a/tests/e2e/waiter.mjs b/tests/e2e/waiter.mjs
index 47e945f..29574f9 100644
--- a/tests/e2e/waiter.mjs
+++ b/tests/e2e/waiter.mjs
@@ -322,6 +322,28 @@ try {
r.check('4.8: more guests than seats is allowed, with a hint (not a limit)', await a.getByTestId('seats-hint').getAttribute('data-over') === 'true')
await a.goto(`${APP}/tables`)
+ // bookings on the phone: a request made online is confirmed and the guests seated (the counter's flow)
+ const sqlite = sql => execFileSync(PYTHON, ['-c', `import sqlite3; c = sqlite3.connect(r"${path.join(backend.dataDir, 'pos.db')}"); r = c.execute(${JSON.stringify(sql)}).fetchall(); c.commit(); print(r)`], { encoding: 'utf8' }).trim()
+ sqlite("insert into reservations (guest_name, party_size, phone, reserved_for, status, source, online_ref, created_at, updated_at) values ('E2E Guest', 2, '6900000000', datetime('now', '+2 hours'), 'requested', 'online', 'ORD-E2E', datetime('now'), datetime('now'))")
+ const waiterRole = await api('GET', '/api/waiters/roles/waiter/permissions', { token: boss })
+ await api('PUT', '/api/waiters/roles/waiter/permissions', { token: boss, body: { keys: [...waiterRole.keys, 'connect_orders.manage'] } })
+ await a.goto(`${APP}/tables`)
+ await a.reload()
+ await a.locator('button').filter({ has: a.locator('svg') }).first().click().catch(() => {})
+ const drawerHasBookings = await a.getByRole('button', { name: 'Bookings' }).isVisible({ timeout: 5000 }).catch(() => false)
+ await a.goto(`${APP}/bookings`)
+ const card = () => a.locator('[data-testid="booking-card"]').filter({ hasText: 'E2E Guest' })
+ await card().first().waitFor({ timeout: 10_000 }).catch(() => {})
+ r.check('4.8: with the online-orders key the phone lists the booking request (drawer: Bookings)', drawerHasBookings && await card().getAttribute('data-status') === 'requested')
+ await card().getByTestId('booking-confirm').click()
+ await waitFor(async () => await card().getAttribute('data-status') === 'pending', 10_000, 300)
+ await card().getByTestId('booking-table').selectOption({ index: 1 })
+ await card().getByTestId('booking-arrive').click()
+ const seated = await waitFor(async () => /arrived', \d+/.test(sqlite("select status, table_id from reservations where online_ref = 'ORD-E2E'")) && 1, 10_000, 500)
+ r.check('4.8: …confirmed and seated at a table from the phone', !!seated, sqlite("select status, table_id from reservations where online_ref = 'ORD-E2E'"))
+ await api('PUT', '/api/waiters/roles/waiter/permissions', { token: boss, body: { keys: waiterRole.default_keys } })
+ await a.goto(`${APP}/tables`)
+
// ── 4.6: the look on the shared tokens: the venue's colour and light / dark reach the phone ──
const accentOf = () => a.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--x-accent-rgb').trim())
r.check('4.6: the venue colour (default amber) is on the phone', await a.evaluate(() => document.documentElement.dataset.venueTheme) === 'amber')
diff --git a/waiter_pwa/src/App.jsx b/waiter_pwa/src/App.jsx
index b4dc8bb..9cd818d 100644
--- a/waiter_pwa/src/App.jsx
+++ b/waiter_pwa/src/App.jsx
@@ -25,6 +25,7 @@ import ChatListPage from './pages/ChatListPage'
import ChatThreadPage from './pages/ChatThreadPage'
import ShiftOverviewPage from './pages/ShiftOverviewPage'
import OrderLogPage from './pages/OrderLogPage'
+import BookingsPage from './pages/BookingsPage'
import { NotificationProvider } from './context/NotificationContext'
import { LiveProvider } from './context/LiveContext'
import ConnectivityBar from './components/ConnectivityBar'
@@ -504,6 +505,7 @@ function Routed() {
} />
} />
} />
+
} />
} />
} />
diff --git a/waiter_pwa/src/components/AppShell.jsx b/waiter_pwa/src/components/AppShell.jsx
index 76b8431..89b7bb0 100644
--- a/waiter_pwa/src/components/AppShell.jsx
+++ b/waiter_pwa/src/components/AppShell.jsx
@@ -275,6 +275,19 @@ const DRAWER_NAV_ITEMS = [
},
{ ...NAV_REGISTRY.orders },
{ ...NAV_REGISTRY.messages },
+ {
+ // table bookings (4.8): for whoever handles online orders or manages reservations
+ key: 'bookings',
+ label: 'nav.bookings',
+ href: '/bookings',
+ match: (loc) => loc.pathname === '/bookings',
+ icon: (
+
+ ),
+ },
{
key: 'shift-overview',
label: 'nav.shiftSummary',
@@ -375,6 +388,10 @@ function SideDrawer({ open, onClose }) {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const chatOn = useChatOn()
+ const bookingsModule = useModule('connect_orders')
+ const bookingsOnline = useCan('connect_orders.manage')
+ const bookingsManage = useCan('reservations.manage')
+ const bookingsOn = bookingsModule && (bookingsOnline || bookingsManage)
const location = useLocation()
const { activeZoneTab, setActiveZoneTab } = useTableViewStore()
@@ -425,7 +442,7 @@ function SideDrawer({ open, onClose }) {
{t('shell.navigation')}
- {DRAWER_NAV_ITEMS.filter(shown(chatOn)).map(item => {
+ {DRAWER_NAV_ITEMS.filter(shown(chatOn)).filter(item => item.key !== 'bookings' || bookingsOn).map(item => {
const isStandaloneActive = location.pathname === '/tables' && activeZoneTab === 'standalone'
const active = item.key === 'standalone'
? isStandaloneActive
diff --git a/waiter_pwa/src/main.jsx b/waiter_pwa/src/main.jsx
index 40b08a0..573e0cf 100644
--- a/waiter_pwa/src/main.jsx
+++ b/waiter_pwa/src/main.jsx
@@ -1,6 +1,6 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
-import '@xenia/ui/tokens.css' // shared --x-* tokens: the waiter's --bg/--text… are made of them (4.6)
+import '@xenia/ui/styles.css' // shared --x-* tokens (the waiter's --bg/--text… are made of them, 4.6) + the .x-* components (4.8)
import './index.css'
// The theme before anything renders (no light flash on a dark phone): the user's light/dark
diff --git a/waiter_pwa/src/pages/BookingsPage.jsx b/waiter_pwa/src/pages/BookingsPage.jsx
new file mode 100644
index 0000000..78b6a97
--- /dev/null
+++ b/waiter_pwa/src/pages/BookingsPage.jsx
@@ -0,0 +1,183 @@
+import { useCallback, useEffect, useState } from 'react'
+import { useFormat, useTranslation } from '@xenia/i18n'
+import { ReasonPicker, reasonText } from '@xenia/ui'
+import AppShell from '../components/AppShell'
+import client from '../api/client'
+import { apiError } from '../api/errors'
+import db from '../db/posdb'
+
+// Table bookings on the phone (plan step 4.8), the counter's flow (terminal BookingPanel):
+// requests made online are confirmed or declined (the guest sees the answer and the reason);
+// today's confirmed bookings are seated at a free table (their food's order moves there) or
+// cancelled / marked as a no-show. For whoever handles online orders or manages reservations.
+const DECLINE_REASONS = ['full', 'closed', 'party']
+const OPEN = ['open', 'partially_paid', 'paid']
+
+export default function BookingsPage() {
+ const { t } = useTranslation('waiter')
+ const [data, setData] = useState(null)
+ const [error, setError] = useState('')
+ const [busy, setBusy] = useState(null)
+ const [declining, setDeclining] = useState(null)
+ const [free, setFree] = useState([])
+
+ const load = useCallback(async () => {
+ try {
+ const r = await client.get('/api/connect/bookings')
+ setData(r.data)
+ setError('')
+ } catch (err) { setError(apiError(err, t('bookings.loadFailed'))) }
+ 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)))
+ } catch { setFree([]) }
+ }, [t])
+
+ useEffect(() => {
+ load()
+ const onLive = e => { if (['reservation_updated', 'order_updated', 'online_reservation'].includes(e.detail?.type)) load() }
+ window.addEventListener('live-event', onLive)
+ window.addEventListener('live-reconnected', load)
+ return () => { window.removeEventListener('live-event', onLive); window.removeEventListener('live-reconnected', load) }
+ }, [load])
+
+ async function run(booking, path, body) {
+ setBusy(booking.id)
+ setError('')
+ try {
+ await client.post(`/api/connect/bookings/${booking.id}/${path}`, body ?? {})
+ setDeclining(null)
+ } catch (err) { setError(apiError(err, t('bookings.failed'))) } finally {
+ setBusy(null)
+ load()
+ }
+ }
+
+ const requested = data?.requested ?? []
+ const upcoming = data?.upcoming ?? []
+ return (
+
+
+ {error &&
{error}
}
+ {!data && !error &&
{t('common.loading')}
}
+ {data && (
+ <>
+
{t('bookings.requests', { count: requested.length })}
+ {requested.length === 0 &&
{t('bookings.noRequests')}
}
+ {requested.map(b => (
+
+
+
+
+
+
+ ))}
+
+
{t('bookings.upcoming', { count: upcoming.length })}
+ {upcoming.length === 0 &&
{t('bookings.noUpcoming')}
}
+ {upcoming.map(b => (
+
+ run(b, 'arrive', { table_id: tableId })}
+ onCancel={status => run(b, 'cancel', { status })} />
+
+ ))}
+ >
+ )}
+
+ {declining && setDeclining(null)} onDecline={reason => run(declining, 'decline', { reason })} />}
+
+ )
+}
+
+const sectionTitle = { fontSize: 12, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, margin: '4px 2px 0' }
+const empty = { color: 'var(--muted)', fontSize: 14, padding: '6px 2px' }
+
+function BookingCard({ booking: b, children }) {
+ const { t } = useTranslation('waiter')
+ const { formatTime, formatDate, formatDateTime, formatMoney } = useFormat()
+ const today = formatDate(b.reserved_for) === formatDate(new Date())
+ return (
+
+
+
+ {today ? t('bookings.today', { time: formatTime(b.reserved_for) }) : formatDateTime(b.reserved_for, 'datetimeShort')}
+
+ {b.ref && {b.ref}}
+
+
+ {b.guest_name} · {t('bookings.people', { count: b.party_size })}
+ {b.table_label && · {b.table_label}}
+
+ {b.phone &&
{b.phone}}
+ {b.note &&
{b.note}
}
+ {b.lines?.length > 0 && (
+
+
+ {b.order_id ? t('bookings.foodSent') : b.fire_at ? t('bookings.foodAt', { time: formatTime(b.fire_at) }) : t('bookings.foodOnConfirm')}
+
+ {b.lines.map((l, i) =>
{l.quantity}× {l.name}
)}
+
{formatMoney(b.total)}
+
+ )}
+ {children}
+
+ )
+}
+
+function SeatControls({ booking, free, busy, onSeat, 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 }))
+ return (
+
+
+
+
+
+
+
+
+ )
+}
+
+function DeclineSheet({ booking, busy, onClose, onDecline }) {
+ const { t } = useTranslation('waiter')
+ const [choice, setChoice] = useState(null)
+ const [other, setOther] = useState('')
+ const options = DECLINE_REASONS.map(r => ({ value: r, label: t(`bookings.reasons.${r}`) }))
+ const reason = reasonText(choice, options, other)
+ return (
+
+
e.stopPropagation()} data-testid="decline-sheet">
+
+
{t('bookings.declineTitle', { name: booking.guest_name })}
+
{t('bookings.declineBody')}
+
+
+
+
+
+
+
+ )
+}