// Management → Scenes (owner 2026-11-21): the venue's modes ("Party mode", "Match night") that are // on or off. Turning one on changes, at once, everything that follows it: the signage schedule // lines that play only in it (Signage → Schedules) and the price rules or deals with the condition // "a scene is on" (Offers & pricing). Several can be on together; one can be on for a while only. // Backend: /api/scenes (routers/scenes.py, services/scenes.py). import { useState } from 'react' import { useQueryClient } from '@tanstack/react-query' import toast from 'react-hot-toast' import { PartyPopper, Pencil, Plus, Trash2 } from 'lucide-react' import { errorMessage } from '@xenia/api' import { useFormat, useTranslation } from '@xenia/i18n' import { Button, Dialog, Dropdown, EmptyState, Field, IconButton, Input, Page, PageHeader, Spinner, Switch, cx } from '@xenia/ui' import { useLiveQuery } from '../../live/useLiveQuery' import { CATEGORY_COLOURS } from '../products/categoryColours' import * as api from './scenesApi' import { FOR, untilOf } from './scenesApi' export default function ScenesPage() { const { t } = useTranslation('manager') const { formatDateTime } = useFormat() const qc = useQueryClient() const { data: scenes, isPending } = useLiveQuery({ queryKey: ['scenes'], queryFn: api.listScenes, events: api.SCENE_EVENTS }) const [editing, setEditing] = useState(null) const [removing, setRemoving] = useState(null) const [forOf, setForOf] = useState({}) const refresh = () => qc.invalidateQueries({ queryKey: ['scenes'] }) const act = async (fn, done) => { try { await fn(); if (done) toast.success(done); refresh(); return true } catch (err) { toast.error(errorMessage(err, t)); return false } } return ( } onClick={() => setEditing({})} data-testid="scene-new">{t('scenes.new')}} /> {isPending ?
: !scenes?.length ? } title={t('scenes.none')} description={t('scenes.noneHint')} /> : (
    {scenes.map(s => (
  • {/* a scene's colour is the venue's choice (data) */}
    {s.active ? {s.until ? t('scenes.onUntil', { time: formatDateTime(s.until, 'datetimeShort') }) : t('scenes.onNow')} : setForOf(f => ({ ...f, [s.id]: v }))} aria-label={t('scenes.for')} options={FOR.map(k => ({ value: k, label: t(`scenes.forOptions.${k || 'off'}`) }))} />} setEditing(s)}> setRemoving(s)}>
  • ))}
)} {editing && setEditing(null)} onSave={body => act(() => (editing.id ? api.updateScene(editing.id, body) : api.createScene(body)), t('scenes.saved')).then(ok => ok && setEditing(null))} />} {removing && ( setRemoving(null)} footer={<> }>

{t('scenes.deleteBody')}

)}
) } function SceneDialog({ scene, onClose, onSave }) { const { t } = useTranslation('manager') const [name, setName] = useState(scene.name ?? '') const [description, setDescription] = useState(scene.description ?? '') const [color, setColor] = useState(scene.color ?? CATEGORY_COLOURS[0]) const [busy, setBusy] = useState(false) return ( }>
setName(e.target.value)} placeholder={t('scenes.namePh')} data-testid="scene-name" /> setDescription(e.target.value)} placeholder={t('scenes.descriptionPh')} />
{t('scenes.colour')}
{CATEGORY_COLOURS.map(c => (
) }