feat(backend,waiter,terminal,manager): +1 on a sent line and changing a line's quantity

Owner 2026-11-23 (plan 6F.5). Product flag one_more_enabled (off by default; product editor).
POST /api/orders/{id}/items/{item}/again: a new line like the old one (choices, removed, note,
course), priced now, sent to the kitchen like any new line. Waiter app and the counter's table
panel: +1 beside such lines; the first tap arms it, more taps count up, 'Send +N' sends, 4 s idle
disarms (no stray sends).
POST /api/orders/{id}/items/{item}/quantity: venue setting orders.quantity_change (off | add_only |
add_and_remove, default off), key ordering.items.change_quantity (owner, store manager; Alembic 0049
grants it); up only changes the line, down cuts a cancelled part ('quantity lowered', split_from_id)
and prints a cancellation only when asked (the dialog presets yes while the kitchen hasn't finished).
Waiter: 'Change quantity' in a line's actions (now -> new, -/+). cut_part() now shared with split.
GET /api/orders/{id} items carry the product's one_more_enabled / unit_type, deal ids, split_from_id,
cancel_reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 08:26:46 +02:00
co-authored by Claude Opus 5.5
parent 0a353c5f97
commit 72e175ab73
35 changed files with 813 additions and 35 deletions
+45
View File
@@ -0,0 +1,45 @@
// "+1" on a sent line (plan 6F.5): one more of the same, sent to the kitchen like any new line.
// Nothing goes out on one stray tap: the first tap arms it (+1), more taps count up (+2, +3…),
// "Send" sends; 4 s without a tap puts it back.
import { useEffect, useRef, useState } from 'react'
import { useTranslation } from '@xenia/i18n'
const WAIT_MS = 4000
export default function OneMore({ onSend }) {
const { t } = useTranslation('waiter')
const [count, setCount] = useState(0)
const [busy, setBusy] = useState(false)
const timer = useRef(null)
useEffect(() => () => clearTimeout(timer.current), [])
const rearm = () => { clearTimeout(timer.current); timer.current = setTimeout(() => setCount(0), WAIT_MS) }
const stop = e => { e.stopPropagation() }
const tap = e => { stop(e); if (busy) return; setCount(c => Math.min(c + 1, 20)); rearm() }
const send = async e => {
stop(e)
if (busy || !count) return
clearTimeout(timer.current)
setBusy(true)
try { await onSend(count) } finally { setBusy(false); setCount(0) }
}
const round = {
width: 40, height: 40, borderRadius: '50%', flexShrink: 0, cursor: 'pointer', fontWeight: 800, fontSize: 14,
border: '1.5px solid rgb(var(--x-success-rgb) / 0.55)', background: count ? 'var(--x-success)' : 'rgb(var(--x-success-rgb) / 0.1)',
color: count ? 'rgb(var(--x-success-fg-rgb))' : 'var(--x-success)',
}
return (
<div onClick={stop} onTouchStart={stop} style={{ display: 'flex', alignItems: 'center', gap: 6, padding: '0 8px 0 4px' }} data-testid="one-more" data-armed={count ? 'true' : 'false'}>
{count > 0 && (
<button type="button" onClick={send} disabled={busy} data-testid="one-more-send" style={{
height: 36, padding: '0 12px', borderRadius: 18, border: 'none', cursor: 'pointer', fontWeight: 800, fontSize: 13,
background: 'var(--x-success)', color: 'rgb(var(--x-success-fg-rgb))', whiteSpace: 'nowrap',
}}>
{busy ? '…' : t('oneMore.send', { count })}
</button>
)}
<button type="button" onClick={tap} aria-label={t('oneMore.label')} style={round} data-testid="one-more-tap">
+{count || 1}
</button>
</div>
)
}
+9 -2
View File
@@ -3,6 +3,8 @@ import useTableViewStore from '../store/tableViewStore'
import { money } from '../i18n'
import { useTranslation } from '@xenia/i18n'
import { fade } from '../logic/colour'
import OneMore from './OneMore'
import { canOneMore } from '../logic/lines'
const fmtPrice = money
@@ -688,7 +690,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
)
}
export default function OrderSummary({ order, selectable = false, selectedIds = [], onToggle, onLongPressItem, waiterMap, courses = [], priceEventsMap = {}, movedItems = {} }) {
export default function OrderSummary({ order, selectable = false, selectedIds = [], onToggle, onLongPressItem, waiterMap, courses = [], priceEventsMap = {}, movedItems = {}, onOneMore }) {
const { t } = useTranslation('waiter')
const kdsDisplayStyle = useTableViewStore(s => s.kdsDisplayStyle || 'badge')
const orderItemLayout = useTableViewStore(s => s.orderItemLayout || 'compact')
@@ -704,8 +706,10 @@ export default function OrderSummary({ order, selectable = false, selectedIds =
<div className="order-summary">
{activeItems.length === 0 && <p style={{ color: 'var(--x-ink-3)', textAlign: 'center' }}>{t('summary.noItems')}</p>}
{activeItems.map((item, idx) => (
// 6F.5: "+1" beside a line whose product allows it, outside the line's own tap area
<div key={item.id} style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ flex: 1, minWidth: 0 }}>
<ItemRow
key={item.id}
item={item}
selectable={selectable}
selected={selectedIds.includes(item.id)}
@@ -719,6 +723,9 @@ export default function OrderSummary({ order, selectable = false, selectedIds =
priceEvents={priceEventsMap[item.id] ?? []}
moved={!!movedItems[item.id]}
/>
</div>
{onOneMore && canOneMore(item) && <OneMore onSend={qty => onOneMore(item, qty)} />}
</div>
))}
<div className="order-summary__total">
<span>{t('common.total')}</span>
@@ -0,0 +1,57 @@
// Change a sent line's quantity (plan 6F.5): nothing is sent to the kitchen again. The current
// quantity stays big beside the new one so a slip is seen; lowering it cancels the difference and
// asks whether to send a cancellation (yes while the kitchen hasn't finished it).
import { useState } from 'react'
import { useTranslation } from '@xenia/i18n'
import { cancelByDefault, lowestQuantity } from '../logic/lines'
export default function QuantityModal({ item, mode, error, busy, onSave, onClose }) {
const { t } = useTranslation('waiter')
const now = item.quantity
const [qty, setQty] = useState(now)
const [ticket, setTicket] = useState(() => cancelByDefault(item))
const low = lowestQuantity(item, mode)
const lowering = qty < now
const step = d => setQty(q => Math.max(low, Math.min(999, q + d)))
const btn = { width: 56, height: 56, borderRadius: '50%', border: '1.5px solid var(--border)', background: 'var(--bg3)', fontSize: 26, fontWeight: 700, color: 'var(--text)', cursor: 'pointer' }
return (
<div className="modal-overlay" onClick={busy ? undefined : onClose}>
<div className="modal-sheet" onClick={e => e.stopPropagation()} data-testid="quantity-sheet">
<div className="modal-handle" />
<h2 className="modal-title">{t('quantity.title')}</h2>
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 14px' }}>{item.product_name || item.product?.name}</p>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 18, marginBottom: 6 }}>
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 12, color: 'var(--muted)', fontWeight: 700 }}>{t('quantity.now')}</div>
<div style={{ fontSize: 30, fontWeight: 800, color: 'var(--muted)' }} data-testid="quantity-now">{now}</div>
</div>
<span style={{ fontSize: 22, color: 'var(--muted)' }}>→</span>
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 12, color: 'var(--muted)', fontWeight: 700 }}>{t('quantity.new')}</div>
<div style={{ fontSize: 44, fontWeight: 800, color: qty === now ? 'var(--text)' : lowering ? 'var(--x-danger)' : 'var(--x-success)' }} data-testid="quantity-new">{qty}</div>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'center', gap: 28, margin: '8px 0 14px' }}>
<button type="button" style={btn} onClick={() => step(-1)} disabled={qty <= low} aria-label={t('quantity.less')} data-testid="quantity-less">−</button>
<button type="button" style={btn} onClick={() => step(1)} aria-label={t('quantity.more')} data-testid="quantity-more">+</button>
</div>
<p style={{ textAlign: 'center', fontSize: 13, color: 'var(--muted)', margin: '0 0 12px' }}>
{qty > now ? t('quantity.upNote', { count: qty - now }) : lowering ? t('quantity.downNote', { count: now - qty }) : t('quantity.noChange')}
</p>
{mode === 'add_only' && <p style={{ textAlign: 'center', fontSize: 12, color: 'var(--muted)', margin: '0 0 12px' }}>{t('quantity.onlyUp')}</p>}
{lowering && (
<label style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '10px 12px', borderRadius: 12, background: 'var(--bg3)', border: '1px solid var(--border)', marginBottom: 12, fontSize: 14 }}>
<input type="checkbox" checked={ticket} onChange={e => setTicket(e.target.checked)} data-testid="quantity-ticket" style={{ width: 20, height: 20 }} />
<span>{t('quantity.sendCancel')}</span>
</label>
)}
{error && <p role="alert" style={{ color: 'var(--x-danger)', fontSize: 13, textAlign: 'center', margin: '0 0 10px' }}>{error}</p>}
<div style={{ display: 'flex', gap: 10 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onClose} disabled={busy}>{t('common.cancel')}</button>
<button className={lowering ? 'btn btn--danger' : 'btn btn--primary'} style={{ flex: 1 }} disabled={busy || qty === now}
onClick={() => onSave(qty, lowering && ticket)} data-testid="quantity-save">{t('quantity.save')}</button>
</div>
</div>
</div>
)
}