// 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 { Page, Tabs } from '@xenia/ui'
import PrintingSettings from '../printing/PrintingSettings'
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'
import IdentitySettings from './sections/IdentitySettings'
const TABS = {
'app-info': () => ,
venue: () => ,
identity: () => ,
'customer-display': () => ,
'menu-tablets': () => ,
security: () => ,
operation: () => ,
colours: () => ,
'print-fonts': () => ,
fiscal: () => ,
development: () => ,
}
export default function SettingsPage() {
const { t } = useTranslation('manager')
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 tabletOn = useModule('menu_tablet')
const tabletKey = useCan('menu_tablet.manage')
const display = displayOn && displayKey
const tablets = tabletOn && tabletKey
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 (
// settings are forms: the page's form width, centred (the page rule, 2026-11-20)
setParams({ tab: id }, { replace: true })}
tabs={tabs.map(id => ({ id, label: t(`settings.tabs.${id}`), testId: `settings-tab-${id}` }))} />}>
)
}