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:
@@ -4,6 +4,8 @@ import ProductPicker from '../components/ProductPicker'
|
||||
import OrderDrawer from '../components/OrderDrawer'
|
||||
import OrderSummaryModal from '../components/OrderSummaryModal'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
import db from '../db/posdb'
|
||||
import { useProductCache } from '../hooks/useProductCache'
|
||||
import useOrderingSettingsStore from '../store/orderingSettingsStore'
|
||||
@@ -195,14 +197,14 @@ export default function AddItemsPage() {
|
||||
_key: Date.now() + Math.random(),
|
||||
}))
|
||||
setCart(initialCart)
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
load()
|
||||
}, [tableId, isStandalone, orderType])
|
||||
|
||||
useEffect(() => {
|
||||
client.get('/api/settings/').then(r => {
|
||||
getVenueSettings().then(r => {
|
||||
const s = r.data
|
||||
if (s?.['orders.courses_enabled']?.value === 'true') {
|
||||
try { setCourses(JSON.parse(s?.['orders.courses']?.value || '[]')) } catch { /* ignore */ }
|
||||
@@ -348,7 +350,7 @@ export default function AddItemsPage() {
|
||||
setTimeout(() => navigate('/tables'), 1200)
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα αποστολής — η παραγγελία δεν στάλθηκε')
|
||||
setError(apiError(err, 'Σφάλμα αποστολής — η παραγγελία δεν στάλθηκε'))
|
||||
} finally {
|
||||
setSending(false)
|
||||
}
|
||||
@@ -685,7 +687,7 @@ export default function AddItemsPage() {
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
{groups.map((group, gi) => (
|
||||
{groups.map((group, _gi) => (
|
||||
<div key={group.course?.id ?? '__none__'} style={{ position: 'relative' }}>
|
||||
{/* Colored left accent bar */}
|
||||
<div style={{
|
||||
@@ -949,7 +951,7 @@ export default function AddItemsPage() {
|
||||
|
||||
// ── Deal Offer Modal ──────────────────────────────────────────────────────────
|
||||
|
||||
function DealOfferModal({ offer, products, onAccept, onDismiss }) {
|
||||
function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
|
||||
const isFreeItem = offer.action_type === 'free_item'
|
||||
const isFreeChoice = offer.action_type === 'free_choice'
|
||||
const isDiscount = ['set_price','add_amount','add_percent','apply_modifier'].includes(offer.action_type)
|
||||
|
||||
Reference in New Issue
Block a user