feat(waiter): the waiter app on the shared foundations (api client, access, i18n), lint clean, starts offline
Plan step 4.1. No visible change to layout or flows. - api/client.js on @xenia/api createApiClient (CS-8 baseURL, 401 → sign out, no answer → backend-offline, err.xenia, the manager-approval retry); the PIN login handles its own 401 (before, a wrong PIN reloaded the page). - <AccessProvider> at the root with an i18n instance: modules, permission keys, venue, language from bootstrap; who is signed in comes with it (no more /api/auth/me polling). packages/access: AccessProvider gains `cache` (the last bootstrap per session; used when the server can't be reached, `offline` in the context, keeps retrying) and `failed` (the app's own screen when there's nothing cached). The waiter caches per venue, shows its offline page (server search) on a first start without a server, retries every 5 s; ServerRediscovery and BundleSync run outside the bootstrap. - Role names → keys: the shift gate and the user menu use core.dashboard.access. - One shared, offline-cached read of the venue settings (api/venueSettings.js) instead of seven GET /api/settings/ calls; apiError() shows backend error codes in the user's language (17 places). - Lint: 78 errors → 0 (unused code, empty catches, two duplicate style keys, a component created during render, refs read during render → state, hooks after an early return); set-state-in-effect is a warning like the manager/terminal; lint in run-all. - Tests: tests/bootstrapCache.test.mjs; e2e browser: an offline restart stays signed in. Android rediscovery waits for what the screen shows instead of fixed sleeps: 10/10 three runs in a row (KI-009). Terminal 3.4 waits for both displays before the sale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import useTableColourStore from '../store/tableColourStore'
|
||||
import useConnectionStore from '../store/connectionStore'
|
||||
import useTableViewStore from '../store/tableViewStore'
|
||||
import client from '../api/client'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
import db from '../db/posdb'
|
||||
import { FlagsIcon, TransferIcon, MergeIcon, PrintIcon, WaiterIcon } from '../components/Icons'
|
||||
|
||||
@@ -111,7 +112,7 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
|
||||
<div style={{ background: 'var(--bg2)', borderRadius: '0 0 16px 16px', padding: '8px 20px 24px', borderTop: '2px solid var(--border)' }}>
|
||||
<p style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', letterSpacing: 1, marginBottom: 8, marginTop: 8 }}>ACTIONS</p>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
|
||||
{QUICK_ACTIONS.map((a, i) => {
|
||||
{QUICK_ACTIONS.map((a, _i) => {
|
||||
const disabled = !order && a.key !== 'flags'
|
||||
return (
|
||||
<button key={a.key} disabled={disabled} onClick={() => { onClose(); onAction(a.key) }} style={{
|
||||
@@ -306,7 +307,7 @@ export default function TableListPage() {
|
||||
const [flagDefs, setFlagDefs] = useState([])
|
||||
const [flagAssignments, setFlagAssignments] = useState([])
|
||||
const [waiters, setWaiters] = useState([]) // waiter objects for avatar lookup
|
||||
const [offline, setOffline] = useState(false)
|
||||
const [, setOffline] = useState(false)
|
||||
const [showFilters, setShowFilters] = useState(false)
|
||||
const [quickModal, setQuickModal] = useState(null)
|
||||
const [canCancel, setCanCancel] = useState(false)
|
||||
@@ -391,7 +392,7 @@ export default function TableListPage() {
|
||||
client.get('/api/tables/groups'),
|
||||
client.get('/api/flags/defs'),
|
||||
client.get('/api/flags/assignments'),
|
||||
client.get('/api/settings/'),
|
||||
getVenueSettings(),
|
||||
client.get('/api/waiters/on-shift'),
|
||||
])
|
||||
|
||||
@@ -452,14 +453,14 @@ export default function TableListPage() {
|
||||
setCancelConfirm(null)
|
||||
setQuickModal(null)
|
||||
load()
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
async function executeMarkAllServed(orderId) {
|
||||
try {
|
||||
await client.post(`/api/kds/orders/${orderId}/items/mark-all-served`)
|
||||
load()
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
// ── SSE live updates ───────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user