feat(manager): every settings tab on v2 (platform-v2 step 6.14a)

- Settings: tabs in the address (?tab=), Fiscal only with the fiscal app, Appearance only with the waiter app
- General: version / update / license / state / uptime, the local network (address by hand or found, the pairing QR),
  what is set up, export / import of the catalogue and the tables (a wrong file refused, two confirmations), support lock
- Sign-in & security: idle lock / sign-out (seconds..hours, warning when sign-out comes first), recovery codes
- Operation: role permissions, waiters' own shifts and takings, card payments, tables and orders, courses (add, rename,
  colour, order), quick notes, table flags (emoji, colour, white/black text, on/off), quick messages, send the QR menu now
- Appearance: the waiter app's table-card colours per state, light and dark, flash, colour picker with opacity, reset
- Fiscal: on/off, driver, folders with a reachability check, clerk / card terminal numbers, receipt end lines, VAT groups
- Development: pretend printing
- dropped: the v1 'automatic store schedule' switches (kept in the browser only, nothing read them) and the second time-zone card
- backend: JSON settings must be JSON (validation.setting_value); fiscal folders are plain paths (were typed json)
- venue colour data in sections/venueColours.js (guard DATA); store/tableColourStore and Settings/tabs deleted
- tests: settings.test.mjs (5), test_settings_json.py, e2e manager.mjs 'settings v2' (12 checks)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 19:41:14 +02:00
co-authored by Claude Opus 5.5
parent bde125bf09
commit f6fcfb7736
27 changed files with 1935 additions and 2819 deletions
@@ -1,48 +1,62 @@
import { useState } from 'react'
// Settings (plan step 6.14a; every tab on v2): General, Venue & language, the customer display and
// menu tablets (with those apps), Sign-in & security, Operation, Appearance (the waiter app's table
// colours), Printing, Fiscal device (with that app) and Development. The tab is in the address
// (?tab=…), so a link or a reload opens the same one. Everything here needs core.settings.manage.
import { useSearchParams } from 'react-router-dom'
import { useCan, useModule } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
import CustomerDisplaySettings from './sections/CustomerDisplaySettings'
import MenuTabletSettings from './sections/MenuTabletSettings'
import VenueSettings from './sections/VenueSettings'
import AppInfoTab from './tabs/AppInfoTab'
import ColoursTab from './tabs/ColoursTab'
import OperationTab from './tabs/OperationTab'
import { Button } from '@xenia/ui'
import PrintingSettings from '../printing/PrintingSettings'
import SecurityTab from './tabs/SecurityTab'
import DevelopmentTab from './tabs/DevelopmentTab'
import FiscalTab from './tabs/FiscalTab'
import { TabGroup } from '../../ui/Tabs'
import CustomerDisplaySettings from './sections/CustomerDisplaySettings'
import DevelopmentSettings from './sections/DevelopmentSettings'
import FiscalSettings from './sections/FiscalSettings'
import MenuTabletSettings from './sections/MenuTabletSettings'
import OperationSettings from './sections/OperationSettings'
import SecuritySettings from './sections/SecuritySettings'
import SystemSettings from './sections/SystemSettings'
import TableColours from './sections/TableColours'
import VenueSettings from './sections/VenueSettings'
const TABS = ['app-info', 'venue', 'customer-display', 'menu-tablets', 'security', 'operation', 'colours', 'print-fonts', 'fiscal', 'development']
const TABS = {
'app-info': () => <SystemSettings />,
venue: () => <div className="max-w-3xl"><VenueSettings /></div>,
'customer-display': () => <div className="max-w-4xl"><CustomerDisplaySettings /></div>,
'menu-tablets': () => <div className="max-w-3xl"><MenuTabletSettings /></div>,
security: () => <SecuritySettings />,
operation: () => <OperationSettings />,
colours: () => <TableColours />,
'print-fonts': () => <PrintingSettings />,
fiscal: () => <FiscalSettings />,
development: () => <DevelopmentSettings />,
}
export default function SettingsPage() {
const { t } = useTranslation('manager')
const [activeTab, setActiveTab] = useState('app-info')
// the customer display's idle screen (3.4): only where there are displays and the user sets them up
const [params, setParams] = useSearchParams()
// tabs that need an app (and, for the screens, the key to set them up)
const displayOn = useModule('customer_display')
const displayKey = useCan('customer_display.manage')
const display = displayOn && displayKey
// guests ordering from the menu tablets (6.6): where there are tablets and the user sets them up
const tabletOn = useModule('menu_tablet')
const tabletKey = useCan('menu_tablet.manage')
const display = displayOn && displayKey
const tablets = tabletOn && tabletKey
const tabs = TABS.filter(id => (id !== 'customer-display' || display) && (id !== 'menu-tablets' || tablets)).map(id => ({ id, label: t(`settings.tabs.${id}`) }))
const waiterApp = useModule('waiter_app')
const fiscal = useModule('fiscal')
const shown = { 'customer-display': display, 'menu-tablets': tablets, colours: waiterApp, fiscal }
const tabs = Object.keys(TABS).filter(id => shown[id] ?? true)
const active = tabs.includes(params.get('tab')) ? params.get('tab') : tabs[0]
const Tab = TABS[active]
return (
<div className="flex flex-col h-full min-h-0">
<TabGroup tabs={tabs} active={activeTab} onChange={setActiveTab} />
<div className="flex-1 overflow-y-auto p-6">
{activeTab === 'app-info' && <AppInfoTab />}
{activeTab === 'venue' && <div className="max-w-3xl"><VenueSettings /></div>}
{activeTab === 'customer-display' && display && <div className="max-w-4xl"><CustomerDisplaySettings /></div>}
{activeTab === 'menu-tablets' && tablets && <div className="max-w-3xl"><MenuTabletSettings /></div>}
{activeTab === 'security' && <SecurityTab />}
{activeTab === 'operation' && <OperationTab />}
{activeTab === 'colours' && <ColoursTab />}
{activeTab === 'print-fonts' && <PrintingSettings />}
{activeTab === 'fiscal' && <FiscalTab />}
{activeTab === 'development' && <DevelopmentTab />}
<div className="h-full flex flex-col min-h-0" data-testid="settings-page">
<div className="shrink-0 border-b border-line bg-surface px-4 lg:px-6 overflow-x-auto">
<div className="flex gap-1 py-2" role="tablist" aria-label={t('settings.title')}>
{tabs.map(id => (
<Button key={id} size="sm" variant={active === id ? 'primary' : 'ghost'} role="tab" aria-selected={active === id}
onClick={() => setParams({ tab: id }, { replace: true })} data-testid={`settings-tab-${id}`}>{t(`settings.tabs.${id}`)}</Button>
))}
</div>
</div>
<div className="flex-1 overflow-y-auto p-4 lg:p-6"><Tab /></div>
</div>
)
}