feat(waiter): where each line came from; QR lines marked, the QR message opens the table (platform-v2 step 4.8b)

- order_items.source (Alembic 0025): waiter | counter | qr | online, set by the server
  (orders.add_priced_items: the phone / manager 'waiter', the counter 'counter'; the QR
  menu's lines 'qr', online orders 'online'; a split line keeps its source); lines of
  existing online orders backfilled 'online'; in the order's item output.
- Waiter: lines the guests sent from the QR menu (or an online order) carry a "📱 QR" /
  "🌐 Online" mark; the qr_order message's banner has "Open the table", and in the bell's
  list the message opens it.
- Tests: source per channel, migration 0025, QR placement marks 'qr'; waiter e2e +1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 09:59:57 +02:00
co-authored by Claude Opus 5.5
parent 198f8ff571
commit 1e8271e370
15 changed files with 124 additions and 9 deletions
+6 -1
View File
@@ -209,6 +209,7 @@ function BellButton({ onClick, count }) {
function NotificationDrawer({ messages, onClose }) {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const { formatTime } = useFormat()
return (
<div className="modal-overlay" onClick={onClose}>
@@ -224,9 +225,13 @@ function NotificationDrawer({ messages, onClose }) {
{messages.map(msg => {
const tableIds = (() => { try { return JSON.parse(msg.table_ids || '[]') } catch { return [] } })()
return (
<div key={msg.id} style={{
<div key={msg.id}
data-testid={msg.message_type === 'qr_order' && tableIds.length ? 'notify-row-table' : undefined}
onClick={msg.message_type === 'qr_order' && tableIds.length ? () => { onClose(); navigate(`/tables/${tableIds[0]}`) } : undefined}
style={{
padding: '12px 4px', borderBottom: '1px solid var(--border)',
display: 'flex', gap: 12, alignItems: 'flex-start',
cursor: msg.message_type === 'qr_order' && tableIds.length ? 'pointer' : undefined,
}}>
<span style={{ fontSize: 20, flexShrink: 0 }}>📢</span>
<div style={{ flex: 1, minWidth: 0 }}>
@@ -382,6 +382,15 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
)
})() : null
// Lines the guests sent themselves (QR menu at the table) or an online order (plan step 4.8)
const sourceBadge = item.source === 'qr' || item.source === 'online' ? (
<span data-testid="item-source" data-source={item.source} title={t(`summary.source.${item.source}`)}
style={{ marginLeft: 6, fontSize: 10, fontWeight: 800, padding: '1px 5px', borderRadius: 4, verticalAlign: 'middle',
background: 'rgb(var(--x-info-rgb) / 0.15)', color: 'var(--x-info)', border: '1px solid rgb(var(--x-info-rgb) / 0.35)' }}>
{item.source === 'qr' ? '📱 QR' : `🌐 ${t('summary.source.onlineShort')}`}
</span>
) : null
const nameEl = (
<span
className={[
@@ -394,6 +403,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
>
{item.product?.name || `#${item.product_id}`}
{courseBadge}
{sourceBadge}
</span>
)
@@ -3,6 +3,7 @@ import useAuthStore from '../store/authStore'
import useNotificationSettingsStore from '../store/notificationSettingsStore'
import client from '../api/client'
import { useTranslation } from '@xenia/i18n'
import { useNavigate } from 'react-router-dom'
const NotificationContext = createContext(null)
@@ -97,6 +98,7 @@ function RichBody({ text }) {
function NotificationBanner({ message, onAck, autoDismiss }) {
const { t } = useTranslation('waiter')
const navigate = useNavigate() // a QR order opens its table (4.8)
const tableIds = (() => { try { return JSON.parse(message.table_ids || '[]') } catch { return [] } })()
const theme = getTheme(message.message_type)
@@ -130,6 +132,17 @@ function NotificationBanner({ message, onAck, autoDismiss }) {
</div>
)}
</div>
{message.message_type === 'qr_order' && tableIds.length > 0 && (
<button
data-testid="notify-open-table"
onClick={() => { onAck(message.id); navigate(`/tables/${tableIds[0]}`) }}
style={{
flexShrink: 0, height: 32, padding: '0 12px', borderRadius: 8,
border: `1px solid ${theme.border}`, background: 'transparent', color: theme.labelColor,
fontSize: 12, fontWeight: 700, cursor: 'pointer',
}}
>{t('notify.openTable')}</button>
)}
<button
onClick={() => onAck(message.id)}
style={{