// Signage (plan steps 5.6a-c): the venue's playlists for its TVs (pick one to edit its timeline and // slides; make a new one for a landscape or a portrait screen), which screen plays what, the // schedules, the message of the day and the weather's town: one tab each. // Backend: /api/signage (routers/signage.py). import { useCallback, useEffect, useState } from 'react' import toast from 'react-hot-toast' import { Monitor, Plus, Smartphone } from 'lucide-react' import { errorMessage } from '@xenia/api' import { useTranslation } from '@xenia/i18n' import { Button, Dialog, EmptyState, Field, Input, Select, Spinner } from '@xenia/ui' import * as api from './signageApi' import PlaylistEditor from './PlaylistEditor' import SchedulesTab from './SchedulesTab' import ScreensTab from './ScreensTab' import SignageSettingsTab from './SignageSettingsTab' const TABS = ['playlists', 'screens', 'schedules', 'settings'] export default function SignagePage() { const { t } = useTranslation('manager') const [list, setList] = useState(null) const [current, setCurrent] = useState(null) const [creating, setCreating] = useState(false) const [tab, setTab] = useState('playlists') const load = useCallback(async () => { try { const l = await api.listPlaylists(); setList(l); return l } catch (err) { toast.error(errorMessage(err, t)); return null } }, [t]) useEffect(() => { load().then(l => { if (l?.length) setCurrent(c => c ?? l[0].id) }) }, [load]) return (

{t('signage.pageTitle')}

{t('signage.intro')}

{TABS.map(k => ( ))}
{tab === 'screens' && } {tab === 'schedules' && } {tab === 'settings' && } {tab !== 'playlists' ? null : !list ?
: (
{current ? load().then(l => setCurrent(l?.[0]?.id ?? null))} /> : }
)} {creating && setCreating(false)} onCreate={async body => { try { const p = await api.createPlaylist(body); setCreating(false); await load(); setCurrent(p.id) } catch (err) { toast.error(errorMessage(err, t)) } }} />}
) } function NewPlaylist({ onClose, onCreate }) { const { t } = useTranslation('manager') const [name, setName] = useState('') const [orientation, setOrientation] = useState('landscape') return ( }>
setName(e.target.value)} placeholder={t('signage.playlistPlaceholder')} data-testid="signage-new-name" />