Files
xenia-pos-local/terminal/src/App.jsx
T
bonaminandClaude Opus 5.5 1b111c0e27 feat: the venue's identity in every app: its colour as the accent of the waiters' phones and every terminal screen, customer display looks on the identity, the signage logo widget falls back to the venue's logo
Settings -> Venue -> accent "The venue's identity" (venue.theme = identity): bootstrap
carries the identity's first colour and logos; @xenia/ui applyVenueTheme makes the
accent tokens (light and dark, readable foregrounds) from it. A display look's
"Colours and logo" can be the venue's identity. Plan 6R.20, F-117.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:30:14 +02:00

60 lines
2.6 KiB
React

// The terminal app's root (plan steps 3.1b, 3.1c; APPS_PLATFORM D-2, D-8, §9): one web app
// for every paired screen, served on :8082 (LAN only).
// DeviceProvider the device (pairing, GET /api/devices/me), who is signed in, the live
// connection, offline
// AccessProvider platform bootstrap (venue, language, modules, keys) for that session;
// retries by itself while the server can't be reached (unattended screens)
// Terminal pairing → sign-in → the device's own app, or a "can't run" screen
// The screen follows the device, not the URL; only the dev pages have routes.
import { lazy, Suspense, useEffect } from 'react'
import { BrowserRouter, Route, Routes } from 'react-router-dom'
import { AccessProvider, useAccess } from '@xenia/access'
import { createI18n } from '@xenia/i18n'
import { applyVenueTheme, Spinner, ToastProvider } from '@xenia/ui'
import client from './api/client'
import DeviceProvider from './device/DeviceProvider'
import { useDevice } from './device/context'
import Terminal from './screens/Terminal'
const i18n = createI18n({ defaultNS: 'terminal' })
// Visual check pages for the shared packages, dev builds only (CS-16)
const UiGallery = import.meta.env.DEV ? lazy(() => import('@xenia/ui/gallery')) : null
const I18nSample = import.meta.env.DEV ? lazy(() => import('@xenia/i18n/sample')) : null
const loading = <main className="min-h-screen flex items-center justify-center"><Spinner /></main>
const AUTO_RETRY_MS = 5_000
function Root() {
const { sessionKey } = useDevice()
return (
<AccessProvider client={client} token={sessionKey} i18n={i18n} loading={loading} autoRetryMs={AUTO_RETRY_MS}>
<ToastProvider placement="bottom-center">
<VenueAccent />
<Terminal />
</ToastProvider>
</AccessProvider>
)
}
/** The venue's own colour as the accent of every screen when the venue chose it (6R.20, Settings →
* Venue → "The venue's identity"); otherwise the screens keep their own accent. */
function VenueAccent() {
const venue = useAccess()?.venue
const colour = venue?.theme === 'identity' ? venue?.identity?.colour : null
useEffect(() => { applyVenueTheme(colour ? 'identity' : null, colour) }, [colour])
return null
}
export default function App() {
return (
<BrowserRouter>
<Routes>
{UiGallery && <Route path="/ui-gallery" element={<Suspense fallback={null}><UiGallery /></Suspense>} />}
{I18nSample && <Route path="/i18n-sample" element={<Suspense fallback={null}><I18nSample /></Suspense>} />}
<Route path="*" element={<DeviceProvider><Root /></DeviceProvider>} />
</Routes>
</BrowserRouter>
)
}