// 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 ?