diff --git a/local_backend/core/modules/api.py b/local_backend/core/modules/api.py index f7fb13e..bf36661 100644 --- a/local_backend/core/modules/api.py +++ b/local_backend/core/modules/api.py @@ -112,6 +112,7 @@ def bootstrap( "timezone": timeutil.venue_tz().key, "language": i18n.venue_language(), "currency": _setting(db, "venue.currency", "EUR"), + "theme": _setting(db, "venue.theme", "amber") or "amber", # the accent colour (4.6, data-venue-theme) "business_day_rollover_hour": timeutil.rollover_hour(), }, "modules": [{"key": m.key, "kind": m.kind} for m in registry().values() if m.key in effective], diff --git a/local_backend/modules/core/manifest.py b/local_backend/modules/core/manifest.py index fbdee60..188e767 100644 --- a/local_backend/modules/core/manifest.py +++ b/local_backend/modules/core/manifest.py @@ -32,6 +32,7 @@ MODULE = Module( SettingDef('venue.language', 'en', 'Default language (en | el) for staff without their own language, and for printed reports/receipts and tickets of zones without one.', type='str'), SettingDef('venue.timezone', 'Europe/Athens', 'IANA time zone of the venue (e.g. Europe/Athens). All times are shown in it; DST is automatic. Applies immediately.', type='str'), SettingDef('venue.name', '', 'Venue name shown on screens and tickets.', type='str'), + SettingDef('venue.theme', 'amber', "Accent colour of the staff apps (the waiter's phones first, plan step 4.6): 'teal' | 'amber' | 'blue' | 'violet' | 'rose'", type='enum', choices=('teal', 'amber', 'blue', 'violet', 'rose')), SettingDef('venue.type', '', 'Kind of venue (restaurant, cafe, bar...), chosen in the setup wizard.', type='str'), SettingDef('venue.currency', 'EUR', 'ISO 4217 currency of all prices.', type='str'), ), diff --git a/local_backend/tests/test_venue_theme.py b/local_backend/tests/test_venue_theme.py new file mode 100644 index 0000000..3d3501e --- /dev/null +++ b/local_backend/tests/test_venue_theme.py @@ -0,0 +1,10 @@ +"""The venue's colour for the staff apps (plan step 4.6): setting venue.theme, in bootstrap.""" + + +def test_venue_theme_reaches_bootstrap(client, make_user, login): + owner = login(make_user(role="owner")) + assert client.get("/api/platform/bootstrap").json()["venue"]["theme"] == "amber" # the waiter's colour so far + assert client.put("/api/settings/venue.theme", headers=owner, json={"value": "blue"}).status_code == 200 + assert client.get("/api/platform/bootstrap").json()["venue"]["theme"] == "blue" + r = client.put("/api/settings/venue.theme", headers=owner, json={"value": "neon"}) + assert r.status_code in (400, 422) diff --git a/manager_dashboard/src/pages/Settings/sections/VenueSettings.jsx b/manager_dashboard/src/pages/Settings/sections/VenueSettings.jsx index 6a6c8c2..ab8b93c 100644 --- a/manager_dashboard/src/pages/Settings/sections/VenueSettings.jsx +++ b/manager_dashboard/src/pages/Settings/sections/VenueSettings.jsx @@ -1,6 +1,7 @@ // Venue language and time zone (plan step 2.6f, D-11, D-12): venue.language is the // language of staff without their own choice and of printed tickets/reports; venue.timezone -// is the zone every time is shown in (applies at once). Both reload bootstrap after saving. +// is the zone every time is shown in (applies at once); venue.theme is the staff apps' accent +// colour (plan step 4.6: the waiter's phones). All reload bootstrap after saving. import { useId, useMemo } from 'react' import { useAccess } from '@xenia/access' import { LANGUAGE_NAMES, useTranslation, useFormat } from '@xenia/i18n' @@ -9,6 +10,8 @@ import { SettingRow, SettingsCard } from './SettingsCard' import { useSettings } from './useSettings' import { timeZones } from './timeZones' +const VENUE_THEMES = ['amber', 'teal', 'blue', 'violet', 'rose'] // packages/ui tokens.css data-venue-theme + export default function VenueSettings() { const { t } = useTranslation('manager') const f = useFormat() @@ -16,6 +19,7 @@ export default function VenueSettings() { const s = useSettings() const langId = useId() const tzId = useId() + const themeId = useId() const tz = s.get('venue.timezone', 'Europe/Athens') const zones = useMemo(() => timeZones(tz), [tz]) if (s.loading) return
@@ -33,6 +37,11 @@ export default function VenueSettings() { onChange={e => s.save('venue.timezone', e.target.value)} options={zones.map(z => ({ value: z, label: z.replace(/_/g, ' ') }))} /> + +