feat(api): @xenia/api + @xenia/access; the manager logs in and loads bootstrap through them

Platform-v2 step 2.5 (APPS_PLATFORM D-7, D-10, §9):
- @xenia/api: createApiClient (app passes its axios; session/device headers,
  err.xenia codes, 401/offline hooks, manager-override retry: ask PIN, grant,
  retry once with X-Xenia-Override); errorMessage; createLiveClient = the
  waiter's WebSocket logic (cursor replay, backoff, online) moved unchanged
- @xenia/access: AccessProvider (bootstrap per session token, language +
  venue formats, translated ui labels, approval dialog), useAccess/useCan/
  useModule, Can, RequireModule
- i18n: errors namespace for every backend code (en/el, test vs core/errors.py),
  override/access texts
- manager: client from createApiClient, AccessProvider in a layout route,
  /kds behind RequireModule, usePermissions from bootstrap keys; login and
  unlock no longer treat a wrong password/PIN as "session ended" (a wrong
  lock-screen PIN used to log the manager out)
- waiter: useWebSocket is a thin wrapper over createLiveClient
- tests: api/access unit tests; new e2e suite tests/e2e/manager.mjs; CS-18

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 20:38:31 +02:00
co-authored by Claude Opus 5.5
parent dbb8d5f0f4
commit 78c8824356
35 changed files with 1419 additions and 196 deletions
+34
View File
@@ -0,0 +1,34 @@
import { EmptyState } from '@xenia/ui'
import { useTranslation } from '@xenia/i18n'
import { useCan, useModule } from './hooks.js'
/**
* Show children only to users holding the key(s).
* <Can perm="catalog.menu.manage"><Button>Edit</Button></Can>
* <Can perm={['reports.view', 'history.view']} fallback={<NoAccess />}>…</Can> (any of them)
* <Can perm={[…]} all>…</Can> (all of them)
*/
export function Can({ perm, all = false, fallback = null, children }) {
return useCan(perm, { all }) ? children : fallback
}
/**
* Render children only if the module is licensed and on; otherwise `fallback`
* (default: a "this feature is turned off" screen).
* <Route path="/kds" element={<RequireModule module="kds"><KdsPage /></RequireModule>} />
*/
export function RequireModule({ module, fallback, children }) {
const on = useModule(module)
if (on) return children
return fallback === undefined ? <ModuleOff /> : fallback
}
export function ModuleOff() {
const { t } = useTranslation('common')
return <EmptyState title={t('access.moduleOffTitle')} description={t('access.moduleOffBody')} />
}
export function NoAccess() {
const { t } = useTranslation('common')
return <EmptyState title={t('access.noAccessTitle')} description={t('access.noAccessBody')} />
}