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:
@@ -44,7 +44,8 @@
|
||||
"orderLog": "Αρχείο Παραγγελιών",
|
||||
"settings": "Ρυθμίσεις",
|
||||
"installApp": "Εγκατάσταση εφαρμογής",
|
||||
"chat": "Chat"
|
||||
"chat": "Chat",
|
||||
"bookings": "Κρατήσεις"
|
||||
},
|
||||
"shell": {
|
||||
"notifications": "Ειδοποιήσεις",
|
||||
@@ -810,5 +811,36 @@
|
||||
"table_one": "Τραπέζι για {{count}}",
|
||||
"table_other": "Τραπέζι για {{count}}",
|
||||
"over": "{{count}} άτομα σε τραπέζι για {{seats}}: εντάξει, είναι μόνο ένδειξη"
|
||||
},
|
||||
"bookings": {
|
||||
"title": "Κρατήσεις",
|
||||
"loadFailed": "Σφάλμα φόρτωσης κρατήσεων",
|
||||
"failed": "Σφάλμα αποθήκευσης",
|
||||
"requests": "Αιτήματα ({{count}})",
|
||||
"noRequests": "Δεν υπάρχουν αιτήματα",
|
||||
"upcoming": "Επιβεβαιωμένες ({{count}})",
|
||||
"noUpcoming": "Δεν υπάρχουν επιβεβαιωμένες κρατήσεις",
|
||||
"confirm": "Επιβεβαίωση",
|
||||
"decline": "Απόρριψη",
|
||||
"today": "Σήμερα {{time}}",
|
||||
"people_one": "{{count}} άτομο",
|
||||
"people_other": "{{count}} άτομα",
|
||||
"foodSent": "Φαγητό εκ των προτέρων: στην κουζίνα",
|
||||
"foodAt": "Φαγητό εκ των προτέρων: στην κουζίνα στις {{time}}",
|
||||
"foodOnConfirm": "Φαγητό εκ των προτέρων: στην κουζίνα μόλις επιβεβαιωθεί",
|
||||
"table": "Τραπέζι",
|
||||
"noTable": "Χωρίς τραπέζι ακόμα",
|
||||
"arrive": "Ήρθαν: τοποθέτηση",
|
||||
"cancel": "Ακύρωση",
|
||||
"noShow": "Δεν ήρθαν",
|
||||
"declineTitle": "Απόρριψη της κράτησης του/της {{name}};",
|
||||
"declineBody": "Ο πελάτης βλέπει τον λόγο.",
|
||||
"reason": "Λόγος",
|
||||
"reasons": {
|
||||
"full": "Είμαστε πλήρεις",
|
||||
"closed": "Είμαστε κλειστά τότε",
|
||||
"party": "Ιδιωτική εκδήλωση",
|
||||
"other": "Άλλος λόγος"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
"orderLog": "Order log",
|
||||
"settings": "Settings",
|
||||
"installApp": "Install the app",
|
||||
"chat": "Chat"
|
||||
"chat": "Chat",
|
||||
"bookings": "Bookings"
|
||||
},
|
||||
"shell": {
|
||||
"notifications": "Notifications",
|
||||
@@ -810,5 +811,36 @@
|
||||
"table_one": "Table for {{count}}",
|
||||
"table_other": "Table for {{count}}",
|
||||
"over": "{{count}} guests at a table for {{seats}}: fine, it is only a suggestion"
|
||||
},
|
||||
"bookings": {
|
||||
"title": "Bookings",
|
||||
"loadFailed": "Couldn't load the bookings",
|
||||
"failed": "Couldn't save the change",
|
||||
"requests": "Requests ({{count}})",
|
||||
"noRequests": "No requests waiting",
|
||||
"upcoming": "Confirmed ({{count}})",
|
||||
"noUpcoming": "No confirmed bookings coming up",
|
||||
"confirm": "Confirm",
|
||||
"decline": "Decline",
|
||||
"today": "Today {{time}}",
|
||||
"people_one": "{{count}} person",
|
||||
"people_other": "{{count}} people",
|
||||
"foodSent": "Food ordered ahead: in the kitchen",
|
||||
"foodAt": "Food ordered ahead: to the kitchen at {{time}}",
|
||||
"foodOnConfirm": "Food ordered ahead: to the kitchen once confirmed",
|
||||
"table": "Table",
|
||||
"noTable": "No table yet",
|
||||
"arrive": "They are here: seat them",
|
||||
"cancel": "Cancel",
|
||||
"noShow": "Didn't come",
|
||||
"declineTitle": "Decline {{name}}'s booking?",
|
||||
"declineBody": "The guest sees the reason.",
|
||||
"reason": "Reason",
|
||||
"reasons": {
|
||||
"full": "We are fully booked",
|
||||
"closed": "We're closed then",
|
||||
"party": "Private event",
|
||||
"other": "Other reason"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import {
|
||||
Button, Dialog, EmptyState, Field, IconButton, InfoTip, Input, PinPad, Select, Sheet,
|
||||
Spinner, Stepper, Switch, Textarea, ToastProvider, useToast,
|
||||
ReasonPicker, Spinner, Stepper, Switch, Textarea, ToastProvider, useToast,
|
||||
} from '../src/index.js'
|
||||
import '../src/styles.css'
|
||||
|
||||
@@ -41,6 +41,8 @@ function Demo() {
|
||||
const [theme, setTheme] = useState('light')
|
||||
const [venue, setVenue] = useState('teal')
|
||||
const [dialog, setDialog] = useState(false)
|
||||
const [reason, setReason] = useState(null)
|
||||
const [reasonOther, setReasonOther] = useState('')
|
||||
const [locked, setLocked] = useState(false)
|
||||
const [sheet, setSheet] = useState(null)
|
||||
const [on, setOn] = useState(true)
|
||||
@@ -139,6 +141,13 @@ function Demo() {
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="ReasonPicker">
|
||||
<div style={{ maxWidth: 360 }}>
|
||||
<ReasonPicker ariaLabel="Reason" value={reason} onChange={setReason} other={reasonOther} onOther={setReasonOther}
|
||||
options={[{ value: 'full', label: 'We are fully booked' }, { value: 'closed', label: 'Closed that day' }]} />
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="Switch + InfoTip">
|
||||
<div style={{ display: 'grid', gap: 'var(--x-space-4)', maxWidth: 520 }}>
|
||||
<Switch checked={on} onChange={setOn} label="Print kitchen tickets" description="Send new items to the kitchen printer." />
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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).
|
||||
* <ReasonPicker options={[{ value: 'full', label: 'We are full' }]} value={choice} onChange={setChoice}
|
||||
* other={text} onOther={setText} otherLabel="Other" ariaLabel="Reason" />
|
||||
* `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 (
|
||||
<div className={cx('x-reasons', className)}>
|
||||
<div className="x-reasons__list" role="radiogroup" aria-label={ariaLabel}>
|
||||
{all.map(o => (
|
||||
<button key={o.value} type="button" role="radio" aria-checked={value === o.value}
|
||||
className={cx('x-reasons__option', value === o.value && 'x-reasons__option--on')}
|
||||
onClick={() => onChange(o.value)} data-testid={`${testIdPrefix}-${o.value}`}>
|
||||
{o.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{value === 'other' && (
|
||||
<input className="x-input" value={other} maxLength={300} autoFocus aria-label={ariaLabel}
|
||||
onChange={e => onOther?.(e.target.value)} data-testid={`${testIdPrefix}-other-text`} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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 ?? ''
|
||||
}
|
||||
@@ -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'
|
||||
|
||||
@@ -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), '')
|
||||
})
|
||||
Reference in New Issue
Block a user