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,7 +4,7 @@ function computeUnread(conversations) {
|
||||
return conversations.reduce((sum, c) => sum + (c.unread_count || 0), 0)
|
||||
}
|
||||
|
||||
const useChatStore = create((set, get) => ({
|
||||
const useChatStore = create((set, _get) => ({
|
||||
conversations: [],
|
||||
totalUnread: 0,
|
||||
// Messages cache: { [convId]: MessageOut[] } — newest first (API order)
|
||||
|
||||
@@ -34,7 +34,6 @@ const useConnectionStore = create((set, get) => ({
|
||||
|
||||
const graceTimer = setTimeout(() => {
|
||||
if (get().status !== 'reconnecting') return
|
||||
const lostAt = get().lostAt
|
||||
|
||||
// Start the 5-min flash timer
|
||||
const flashTimer = setTimeout(() => {
|
||||
|
||||
@@ -104,7 +104,7 @@ const useTableColourStore = create((set) => ({
|
||||
}
|
||||
set({ colours: merged })
|
||||
}
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
},
|
||||
}))
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { storageKey } from '../config/server'
|
||||
|
||||
const useTableViewStore = create(
|
||||
persist(
|
||||
(set, get) => ({
|
||||
(set, _get) => ({
|
||||
density: '2x2',
|
||||
ownerFilter: 'all',
|
||||
statusFilter: 'all',
|
||||
|
||||
@@ -87,7 +87,7 @@ const useWaiterFavoritesStore = create(
|
||||
try {
|
||||
const res = await client.get('/api/auth/me/settings')
|
||||
existing = JSON.parse(res.data?.settings || '{}')
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
|
||||
const { favorites, quickNotes, itemFavorites } = get()
|
||||
const merged = { ...existing, [SETTINGS_KEY]: { favorites, quickNotes, itemFavorites } }
|
||||
|
||||
Reference in New Issue
Block a user