- manager: new pages/orders/ (Tables page cards + quick actions, order page with
lines, multi-select pay/discount/cancel/tab, staff + customer, price changes,
history, the menu + cart beside it); a free table opens a new order on first
Send; v1 TablesPage, OrderDetailPage, DesktopOrderingTab, ManagerOrderDrawer
and PaymentMethodModal removed
- ordering by line id like the phones: GET /api/orders/menu (the counter's
product shape, in-store prices); the product dialog, cart rules and quote hook
move to packages/ordering (@xenia/ordering), shared by counter, menu tablet,
manager
- close follows orders.close_with_unpaid (pay first, or write off after saying
so) on the order page and the overview's quick view; paying asks cash or card
- a confirmed booking can keep its table ahead (manager, phones, counter):
POST /api/connect/bookings/{id}/table, reservations create/PATCH; refused with
reservation.table_kept within 2 h of another booking
- tests: test_manager_ordering.py, online bookings +2, manager orders.test.mjs,
@xenia/ordering, e2e manager.mjs (take, change, pay-first close, RESERVED)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.4 KiB
JavaScript
30 lines
1.4 KiB
JavaScript
// The server's price for a cart, asked again shortly after it changes (plan steps 3.3a, 6.9).
|
|
// `fetchQuote(lines)` is the app's call (the counter: /api/pos/quote; the manager and the phones:
|
|
// /api/orders/quote; the menu tablet: its own). Only the latest answer counts.
|
|
import { useEffect, useRef, useState } from 'react'
|
|
|
|
const QUOTE_DELAY_MS = 120
|
|
|
|
export function useQuote(fetchQuote, lines, extraKey = '') {
|
|
const [state, setState] = useState({ quote: null, pending: false, error: null })
|
|
const seq = useRef(0)
|
|
const fn = useRef(fetchQuote)
|
|
useEffect(() => { fn.current = fetchQuote })
|
|
const key = JSON.stringify([lines, extraKey])
|
|
useEffect(() => {
|
|
const mine = ++seq.current
|
|
if (!lines.length) { setState({ quote: { lines: [], total: 0 }, pending: false, error: null }); return undefined } // eslint-disable-line react-hooks/set-state-in-effect
|
|
setState(s => ({ ...s, pending: true }))
|
|
const id = setTimeout(async () => {
|
|
try {
|
|
const data = await fn.current(lines)
|
|
if (mine === seq.current) setState({ quote: data, pending: false, error: null })
|
|
} catch (err) {
|
|
if (mine === seq.current) setState(s => ({ ...s, pending: false, error: err }))
|
|
}
|
|
}, QUOTE_DELAY_MS)
|
|
return () => clearTimeout(id)
|
|
}, [key]) // eslint-disable-line react-hooks/exhaustive-deps -- `key` is the lines + the caller's extra key
|
|
return state
|
|
}
|