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:
@@ -0,0 +1,34 @@
|
||||
// "+1" on a sent line at the counter (plan 6F.5; the waiter app has the same): the first tap arms
|
||||
// it, more taps count up, "Send +N" sends one more of the same line (printed as new); 4 s without
|
||||
// a tap puts it back. Nothing is sent by one stray tap.
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button } from '@xenia/ui'
|
||||
|
||||
const WAIT_MS = 4000
|
||||
|
||||
export default function OneMore({ onSend }) {
|
||||
const { t } = useTranslation('terminal')
|
||||
const [count, setCount] = useState(0)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const timer = useRef(null)
|
||||
useEffect(() => () => clearTimeout(timer.current), [])
|
||||
const tap = () => {
|
||||
if (busy) return
|
||||
setCount(c => Math.min(c + 1, 20))
|
||||
clearTimeout(timer.current)
|
||||
timer.current = setTimeout(() => setCount(0), WAIT_MS)
|
||||
}
|
||||
const send = async () => {
|
||||
if (busy || !count) return
|
||||
clearTimeout(timer.current)
|
||||
setBusy(true)
|
||||
try { await onSend(count) } finally { setBusy(false); setCount(0) }
|
||||
}
|
||||
return (
|
||||
<span className="flex items-center gap-1.5 shrink-0 px-2" data-testid="one-more" data-armed={count ? 'true' : 'false'}>
|
||||
{count > 0 && <Button size="sm" variant="primary" loading={busy} onClick={send} data-testid="one-more-send">{t('pos.oneMore.send', { count })}</Button>}
|
||||
<Button size="sm" variant={count ? 'primary' : 'secondary'} onClick={tap} aria-label={t('pos.oneMore.label')} data-testid="one-more-tap">+{count || 1}</Button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import client from '../../api/client'
|
||||
import CartLine from './CartLine'
|
||||
import { setLineQty } from './logic/cart'
|
||||
import { itemPayments, orderLines, orderSums, qtyLabel, tableState, toPay } from './logic/tables'
|
||||
import OneMore from './OneMore'
|
||||
import PaymentDialog from './PaymentDialog'
|
||||
import { PaidSummary } from './SaleCart'
|
||||
import { useOrder, useQuote } from './usePos'
|
||||
@@ -111,7 +112,14 @@ export default function TablePanel({ table, cart, setCart, byId, canDiscount, on
|
||||
<span>{t('pos.table.onOrder')}</span><span>{formatMoney(sums.total)}</span>
|
||||
</h3>
|
||||
{lines.map(l => (
|
||||
<OrderLine key={l.id} line={l} selected={selected.includes(l.id)} onToggle={() => toggle(l.id)} />
|
||||
<div key={l.id} className="flex items-center border-b border-line">
|
||||
<div className="flex-1 min-w-0"><OrderLine line={l} selected={selected.includes(l.id)} onToggle={() => toggle(l.id)} /></div>
|
||||
{l.oneMore && <OneMore onSend={qty => run(async () => {
|
||||
await client.post(`/api/orders/${orderId}/items/${l.id}/again`, { quantity: qty })
|
||||
toast.success(t('pos.oneMore.sent', { count: qty, name: l.name }))
|
||||
reload()
|
||||
})} />}
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
@@ -230,11 +238,11 @@ function OrderLine({ line, selected, onToggle }) {
|
||||
</>
|
||||
)
|
||||
if (line.paid) {
|
||||
return <div className="px-3 py-2 border-b border-line text-ink-3" data-testid="order-line" data-item={line.id} data-paid="true">{body}</div>
|
||||
return <div className="px-3 py-2 text-ink-3" data-testid="order-line" data-item={line.id} data-paid="true">{body}</div>
|
||||
}
|
||||
return (
|
||||
<button type="button" onClick={onToggle} aria-pressed={selected} data-testid="order-line" data-item={line.id} data-paid="false"
|
||||
className={`w-full text-left px-3 py-2 border-b border-line transition-colors duration-fast ${selected ? 'bg-accent-soft text-accent-ink' : 'text-ink hover:bg-surface-2'}`}>
|
||||
className={`w-full text-left px-3 py-2 transition-colors duration-fast ${selected ? 'bg-accent-soft text-accent-ink' : 'text-ink hover:bg-surface-2'}`}>
|
||||
{body}
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -58,6 +58,8 @@ export function orderLines(order) {
|
||||
notes: i.notes,
|
||||
kds: i.kds_status ?? 'pending',
|
||||
system: i.system_key ?? null, // a line the system added: 'delivery_fee' (phase 3S)
|
||||
// "+1" (6F.5): the product allows it, in pieces, not a deal's line
|
||||
oneMore: !!i.product?.one_more_enabled && (i.unit_type ?? 'piece') === 'piece' && !i.deal_id && !i.linked_item_id,
|
||||
}))
|
||||
return [...lines.filter(l => !l.paid), ...lines.filter(l => l.paid)]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user