feat(waiter): a table's earlier orders (platform-v2 step 4.7)
- GET /api/tables/{id}/history: the table's closed / cancelled orders, newest first,
for the waiters of its zone (ordering.orders.open), never older than the history
module's history_days (free tier 31, D-6), module.disabled when history is off;
each order with times, total (cancelled items left out), people and items.
- Waiter: a History tab on the table (and "This table's earlier orders" on a free
table); orders expand to their items; the last answer is kept on the phone and
shown offline, marked as saved; the plan's day limit is shown.
- Tests: test_table_history.py (4), waiter e2e +2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
import { useAllowed, useCan } from '@xenia/access'
|
||||
import { useAllowed, useCan, useModule } from '@xenia/access'
|
||||
import OrderSummary from '../components/OrderSummary'
|
||||
import TableHistory from '../components/TableHistory'
|
||||
import useConnectionStore from '../store/connectionStore'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
@@ -1079,6 +1080,8 @@ export default function TableDetailPage() {
|
||||
|
||||
// Tab: 'active' | 'paid'
|
||||
const [activeTab, setActiveTab] = useState('active')
|
||||
const historyOn = useModule('history') // 4.7: a table's earlier orders
|
||||
const [showHistory, setShowHistory] = useState(false)
|
||||
|
||||
// Actions sheet state
|
||||
const [showActions, setShowActions] = useState(false)
|
||||
@@ -1702,6 +1705,12 @@ export default function TableDetailPage() {
|
||||
<button className="btn btn--primary btn--lg" onClick={openOrder}>
|
||||
{t('detail.openOrder')}
|
||||
</button>
|
||||
{historyOn && (
|
||||
<button className="btn btn--secondary" data-testid="history-open" style={{ marginTop: 12 }} onClick={() => setShowHistory(s => !s)}>
|
||||
{t('history.earlier')}
|
||||
</button>
|
||||
)}
|
||||
{historyOn && showHistory && <div style={{ width: '100%', maxHeight: '50vh', overflowY: 'auto' }}><TableHistory tableId={Number(tableId)} /></div>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1780,6 +1789,21 @@ export default function TableDetailPage() {
|
||||
}}>{paidItems.length}</span>
|
||||
)}
|
||||
</button>
|
||||
{historyOn && !isStandalone && (
|
||||
<button
|
||||
data-testid="tab-history"
|
||||
onClick={() => setActiveTab('history')}
|
||||
style={{
|
||||
flex: 1, padding: '9px 0', border: 'none', cursor: 'pointer',
|
||||
fontWeight: 700, fontSize: 13,
|
||||
background: activeTab === 'history' ? 'var(--bg3)' : 'transparent',
|
||||
color: activeTab === 'history' ? 'var(--text)' : 'var(--muted)',
|
||||
transition: 'background 0.15s',
|
||||
}}
|
||||
>
|
||||
{t('history.tab')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Merge view button */}
|
||||
@@ -1804,6 +1828,8 @@ export default function TableDetailPage() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{activeTab === 'history' && <TableHistory tableId={Number(tableId)} />}
|
||||
|
||||
{activeTab === 'active' && (
|
||||
<>
|
||||
<OrderSummary
|
||||
|
||||
Reference in New Issue
Block a user