feat(signage,scenes): schedule lines with screens and smart days, screens' defaults, horizontal timeline, scenes

- Scenes (Alembic 0043, models/scene.py, /api/scenes, core.scenes.manage): named
  modes on or off (optionally until a time); price rules / deals get the
  condition "a scene is on"; signage lines can play only during a scene;
  turning one on tells every screen and pushes the online menu.
- Signage schedules are lines (signage_schedule_items): playlist, screens
  ([] = every screen), priority, days, smart days (1st / last day, first / last
  week, Greek public holidays or not: core/calendar_days.py, mirrored in
  @xenia/signage), hours, dates, scene. No line → the screen's default
  playlist. 0043 turns the old named schedules into lines for their screens.
- Screens: default playlist, TV shape, turn; what plays now and why.
- Manager: tabs Screens · Playlists · Schedules · Slides (placeholder) ·
  Message and weather; schedule lines with playlist / screens / priority /
  delete on one line; the playlist editor's horizontal timeline of fixed
  cards, the slide's basics beside its preview (one height), then its content;
  Management → Scenes; the scene condition in pricing.
- Tests: backend (lines, smart days, scenes, prices), player logic, e2e.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 19:22:47 +02:00
co-authored by Claude Opus 5.5
parent abab158b7c
commit 60e6a16217
44 changed files with 1429 additions and 533 deletions
@@ -4,7 +4,7 @@ import { useState } from 'react'
import { ArrowDown, ArrowUp, Check, Pencil, Plus, Power, Trash2, X } from 'lucide-react'
import { SALES_POINTS, normalizeSalesPoints } from '@xenia/access'
import { latin, useFormat, useTranslation } from '@xenia/i18n'
import { Button, IconButton, Input, Select, cx } from '@xenia/ui'
import { Button, Dropdown, IconButton, Input, Select, cx } from '@xenia/ui'
import { COLOURS } from './useCatalog'
import { OLD_PLACEHOLDERS, WEEKDAYS, blankCondition, conditionComplete, toggleIn } from './pricingLogic'
@@ -220,6 +220,12 @@ function ConditionFields({ cond, onChange, catalog }) {
placeholder={catalog.groups.length ? t('pricing.choose') : t('pricing.condition.noGroups')}
options={catalog.groups.map(g => ({ value: g.id, label: g.name }))} />
)
case 'scene_active': return (
<Dropdown size="sm" value={p.scene_id ?? null} aria-label={t('pricing.condition.fields.scene_id')} data-testid="pricing-cond-scene"
onChange={v => set('scene_id', v == null || v === '' ? null : Number(v))}
placeholder={catalog.scenes.length ? t('pricing.choose') : t('pricing.condition.noScenes')}
options={catalog.scenes.map(s => ({ value: s.id, label: s.name, dot: s.color || undefined }))} />
)
default: return null
}
}
@@ -6,10 +6,10 @@
export const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6] // Monday = 0, as the server counts
// conditions a rule can have; the deals take fewer
export const MODIFIER_CONDITIONS = ['time_range', 'day_of_week', 'date_range', 'specific_date', 'price_group_active',
export const MODIFIER_CONDITIONS = ['time_range', 'day_of_week', 'date_range', 'specific_date', 'price_group_active', 'scene_active',
'order_channel', 'min_item_quantity', 'min_category_qty', 'min_order_value']
export const DEAL_CONDITIONS = ['min_item_quantity', 'min_order_value', 'time_range', 'day_of_week', 'date_range',
'order_channel', 'price_group_active']
'order_channel', 'price_group_active', 'scene_active']
export const OLD_PLACEHOLDERS = ['user_tier', 'low_stock'] // never did anything; shown, not offered
export const MODIFIER_TARGETS = ['all', 'item', 'category', 'prep_zone', 'tag']
@@ -31,6 +31,7 @@ export function blankCondition(type) {
case 'min_order_value': return { condition_type: type, params: { min: 20 } }
case 'order_channel': return { condition_type: type, params: { channels: [] } }
case 'price_group_active': return { condition_type: type, params: { price_group_id: null } }
case 'scene_active': return { condition_type: type, params: { scene_id: null } } // a scene is on (2026-11-21)
default: return { condition_type: type, params: {} }
}
}
@@ -51,6 +52,7 @@ export function conditionComplete({ condition_type: type, params: p = {} }) {
case 'min_order_value': return positive(p.min ?? 0, 0)
case 'order_channel': return (p.channels ?? []).length > 0
case 'price_group_active': return Number.isInteger(p.price_group_id)
case 'scene_active': return Number.isInteger(p.scene_id)
default: return OLD_PLACEHOLDERS.includes(type)
}
}
@@ -1,10 +1,11 @@
// What the pricing rules can point at (plan step 6.7), loaded once and kept current: products,
// categories (as a tree), prep zones, tags and price groups; and the colours a rule can have.
// categories (as a tree), prep zones, tags, price groups and scenes; and the colours a rule can have.
import { useMemo } from 'react'
import { useLiveQuery } from '../../live/useLiveQuery'
import { CATEGORY_COLOURS } from '../products/categoryColours'
import { categoryTree, treeLabel } from '../products/productsLogic'
import * as api from './pricingApi'
import { SCENE_EVENTS, listScenes } from '../scenes/scenesApi'
export const COLOURS = CATEGORY_COLOURS // the venue's colours (data, as the categories')
@@ -14,6 +15,7 @@ export function useCatalog() {
const zones = useLiveQuery({ queryKey: ['prep-zones'], queryFn: api.listPrepZones, staleTime: 60_000 })
const tags = useLiveQuery({ queryKey: ['product-tags'], queryFn: api.listTags, staleTime: 60_000 })
const groups = useLiveQuery({ queryKey: ['pricing', 'groups'], queryFn: api.listGroups, events: api.PRICING_EVENTS })
const scenes = useLiveQuery({ queryKey: ['scenes'], queryFn: listScenes, events: SCENE_EVENTS })
return useMemo(() => ({
products: (products.data ?? []).filter(p => p.lifecycle_status !== 'archived' && !p.is_service_item)
.sort((a, b) => a.name.localeCompare(b.name)).map(p => ({ id: p.id, name: p.name, price: p.base_price })),
@@ -21,6 +23,7 @@ export function useCatalog() {
zones: (zones.data ?? []).map(z => ({ id: z.id, name: z.name })),
tags: tags.data ?? [],
groups: groups.data ?? [],
}), [products.data, categories.data, zones.data, tags.data, groups.data])
scenes: scenes.data ?? [],
}), [products.data, categories.data, zones.data, tags.data, groups.data, scenes.data])
}