diff --git a/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx b/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx
index 6f06e03..fa4554d 100644
--- a/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx
+++ b/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx
@@ -1,15 +1,22 @@
-// Settings → Customer display (plan step 3.4). What the customer displays show between sales,
-// the venue's own style (owner, 2026-11-16): the name, the logo, both, nothing, one image, a
-// slideshow of photos, or a QR code (the venue's ordering link, its QR menu, or any link), with
-// an optional line of text, dark or light. Images are uploaded here (JPG/PNG/WebP/GIF, ≤ 5 MB).
-// Saving reaches every display at once. Backend: /api/display/settings, /api/display/media.
-import { useCallback, useEffect, useRef, useState } from 'react'
+// Settings → Customer display (plan steps 3.4, 5.3). What the customer displays show between
+// sales is a **look** the venue designs (owner, 2026-11-16: "configurable, so each venue can
+// choose their style"): the name, the logo, both, nothing, one picture, a slideshow, or a QR code
+// (the venue's ordering link, its QR menu, or any link), with an optional line of text, dark or
+// light. A venue can have several looks; one is the default and each display can show its own
+// (also its "Idle screen" in Devices). Pictures come from the media library (Management → Media).
+// Saving reaches the displays that show the look at once.
+// Backend: /api/display/looks, /api/display/displays (routers/customer_display.py).
+import { useCallback, useEffect, useMemo, useState } from 'react'
import toast from 'react-hot-toast'
-import { Check, ImagePlus, Trash2 } from 'lucide-react'
+import { ArrowLeft, ArrowRight, Check, Images, Plus, Star, Trash2, X } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
-import { Button, Field, IconButton, Input, Select, Spinner } from '@xenia/ui'
+import { Button, Dialog, Field, IconButton, Input, Select, Spinner, Switch } from '@xenia/ui'
import client from '../../../api/client'
+import MediaField from '../../media/MediaField'
+import MediaPicker from '../../media/MediaPicker'
+import { imageOf } from '../../media/mediaLogic'
+import { MediaThumb } from '../../media/MediaParts'
import { useSettings } from './useSettings'
const STYLES = ['name', 'logo', 'name_logo', 'blank', 'image', 'slideshow', 'qr']
@@ -17,59 +24,53 @@ const STYLES = ['name', 'logo', 'name_logo', 'blank', 'image', 'slideshow', 'qr'
export default function CustomerDisplaySettings() {
const { t } = useTranslation('manager')
const venue = useSettings()
- const [data, setData] = useState(null)
- const [form, setForm] = useState(null)
+ const [looks, setLooks] = useState(null)
+ const [displays, setDisplays] = useState([])
+ const [current, setCurrent] = useState(null) // the look being edited (id)
+ const [form, setForm] = useState(null) // its config
+ const [pics, setPics] = useState({}) // media id → image {id, name, thumb, card, full}
+ const [lookName, setLookName] = useState('')
const [busy, setBusy] = useState(false)
- const [name, setName] = useState(null)
- const fileRef = useRef(null)
+ const [venueName, setVenueName] = useState(null)
+ const [adding, setAdding] = useState(false)
+ const [confirmDelete, setConfirmDelete] = useState(false)
- const load = useCallback(async () => {
+ const open = useCallback(look => {
+ setCurrent(look.id)
+ setForm(look.config)
+ setLookName(look.name)
+ setPics(p => ({ ...p, ...Object.fromEntries(Object.entries(look.pictures || {}).map(([k, v]) => [Number(k), v])) }))
+ }, [])
+
+ const load = useCallback(async (pick) => {
try {
- const { data: d } = await client.get('/api/display/settings')
- setData(d)
- setForm(f => f ?? d.idle)
- } catch (err) { toast.error(errorMessage(err, t)) }
- }, [t])
- useEffect(() => { load() }, [load])
+ const [{ data: ls }, { data: ds }] = await Promise.all([client.get('/api/display/looks'), client.get('/api/display/displays')])
+ setLooks(ls)
+ setDisplays(ds)
+ const target = ls.find(l => l.id === pick) || null
+ if (target) open(target)
+ return ls
+ } catch (err) { toast.error(errorMessage(err, t)); return null }
+ }, [t, open])
+ useEffect(() => { load().then(ls => { if (ls?.length) open(ls[0]) }) }, [load, open])
+
+ const look = looks?.find(l => l.id === current)
+ const dirty = useMemo(() => look && (JSON.stringify(look.config) !== JSON.stringify(form) || lookName.trim() !== look.name), [look, form, lookName])
+ if (!looks || !form || !look || venue.loading) return
- if (!data || !form || venue.loading) return
const set = (k, v) => setForm(f => ({ ...f, [k]: v }))
- const media = data.media
- const needs = { logo: ['logo', 'name_logo'], image: ['image'], slides: ['slideshow'], qr: ['qr'] }
- const shows = part => needs[part].includes(form.style)
+ const shows = part => ({ logo: ['logo', 'name_logo'], image: ['image'], slides: ['slideshow'], qr: ['qr'] })[part].includes(form.style)
+ const picOf = id => (id ? pics[id] ?? null : null)
+ const setPic = (key, image) => { if (image) setPics(p => ({ ...p, [image.id]: image })); set(key, image?.id ?? null) }
- const save = async () => {
+ const act = async (fn, done, pick = current) => {
setBusy(true)
- try {
- const { data: d } = await client.put('/api/display/settings', form)
- setData(d)
- setForm(d.idle)
- toast.success(t('settings.saved'))
- } catch (err) { toast.error(errorMessage(err, t)) }
+ try { await fn(); if (done) toast.success(done); await load(pick) } catch (err) { toast.error(errorMessage(err, t)) }
setBusy(false)
}
- const upload = async e => {
- const files = [...(e.target.files ?? [])]
- e.target.value = ''
- for (const file of files) {
- const body = new FormData()
- body.append('file', file)
- try {
- const { data: m } = await client.post('/api/display/media', body)
- setData(d => ({ ...d, media: [...d.media, m] }))
- if (form.style === 'slideshow') setForm(f => ({ ...f, slides: [...f.slides, m.name] }))
- } catch (err) { toast.error(errorMessage(err, t)) }
- }
- }
- const remove = async m => {
- try {
- await client.delete(`/api/display/media/${m.name}`)
- setData(d => ({ ...d, media: d.media.filter(x => x.name !== m.name) }))
- setForm(f => ({ ...f, logo: f.logo === m.name ? null : f.logo, image: f.image === m.name ? null : f.image,
- slides: f.slides.filter(n => n !== m.name) }))
- } catch (err) { toast.error(errorMessage(err, t)) }
- }
- const toggleSlide = n => set('slides', form.slides.includes(n) ? form.slides.filter(x => x !== n) : [...form.slides, n])
+ const save = () => act(() => client.put(`/api/display/looks/${look.id}`, { name: lookName.trim() || look.name, config: form }), t('settings.saved'))
+ const lookLabel = l => `${l.name}${l.is_default ? ` (${t('display.looks.default')})` : ''}`
+ const defaultLook = looks.find(l => l.is_default)
return (
@@ -78,101 +79,210 @@ export default function CustomerDisplaySettings() {
{t('display.intro')}
-
-
{t('display.style')}
-
- {STYLES.map(s => (
-