- The waiter's --bg/--text/--accent… are made of @xenia/ui tokens: light / dark (user menu) and the venue's accent reach every screen; the 751 colour literals in waiter_pwa/src became tokens (by hue family and lightness), hex-alpha suffixes became fade() (color-mix), fixing 'var(--accent)18' tints that never showed. - @xenia/ui: new `special` (violet: offers, discounts, deals; contrast-tested) and `on-colour` tokens. - Setting venue.theme (teal | amber | blue | violet | rose, default amber), bootstrap venue.theme, manager Settings → Venue → Colour; the waiter sets data-venue-theme and the theme before the first render. - Guard tests/no-colours.test.mjs; tests/e2e/waiter_look.mjs (every page light + dark, side-by-side compare page); waiter e2e +3; backend test_venue_theme.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
2.7 KiB
React
78 lines
2.7 KiB
React
import client from '../api/client'
|
|
import { deliveryMode } from '../config/server'
|
|
import { canRediscover, rediscover } from '../native/autoRediscover'
|
|
import { useState } from 'react'
|
|
import { useTranslation } from '@xenia/i18n'
|
|
|
|
// Shown at /offline, and (plan step 4.1) instead of the whole app when the server can't be
|
|
// reached on a start with no cached bootstrap (the app retries by itself and then opens the
|
|
// screen the address asks for).
|
|
export default function OfflinePage() {
|
|
const { t } = useTranslation('waiter')
|
|
const [checking, setChecking] = useState(false)
|
|
const [search, setSearch] = useState(null) // null | { done, total } | 'not-found'
|
|
|
|
async function retry() {
|
|
setChecking(true)
|
|
try {
|
|
await client.get('/api/system/health')
|
|
window.location.href = '/'
|
|
} catch {
|
|
setChecking(false)
|
|
}
|
|
}
|
|
|
|
// Native app: look for this venue's server at a new address on the same network
|
|
async function searchNetwork() {
|
|
setSearch({ done: 0, total: 253 })
|
|
const result = await rediscover({ force: true, onProgress: (done, total) => setSearch({ done, total }) })
|
|
if (result.status === 'moved' || result.status === 'reachable') {
|
|
window.location.href = '/'
|
|
} else {
|
|
setSearch('not-found')
|
|
}
|
|
}
|
|
|
|
const searching = search && search !== 'not-found'
|
|
|
|
return (
|
|
<div className="page page--centered">
|
|
<div style={{ textAlign: 'center', maxWidth: 300 }}>
|
|
<p style={{ fontSize: 48, marginBottom: 16 }}>📡</p>
|
|
<h2 style={{ color: 'var(--x-ink)', marginBottom: 8 }}>{t('offline.title')}</h2>
|
|
<p style={{ color: 'var(--x-ink-3)', marginBottom: 32 }}>
|
|
{t('offline.body')}
|
|
</p>
|
|
<button className="btn btn--primary btn--lg" onClick={retry} disabled={checking || searching}>
|
|
{checking ? t('venues.checking') : t('common.retry')}
|
|
</button>
|
|
{canRediscover() && (
|
|
<button
|
|
className="btn btn--secondary btn--lg"
|
|
style={{ marginTop: 12 }}
|
|
onClick={searchNetwork}
|
|
disabled={searching}
|
|
>
|
|
{searching ? t('offline.searching', { done: search.done, total: search.total }) : t('offline.search')}
|
|
</button>
|
|
)}
|
|
{search === 'not-found' && (
|
|
<p style={{ color: 'var(--x-ink-2)', fontSize: 13, marginTop: 12, lineHeight: 1.45 }}>
|
|
{t('offline.notFound')}
|
|
</p>
|
|
)}
|
|
{deliveryMode() === 'native' && (
|
|
<button
|
|
className="btn btn--secondary btn--lg"
|
|
style={{ marginTop: 12 }}
|
|
onClick={() => { window.location.href = '/venues' }}
|
|
disabled={searching}
|
|
>
|
|
{t('offline.changeVenue')}
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|