- Badges: the venue's list (setting signage.badges: names el/en, colours, an icon from a food and drink set) edited under Signage -> "Message & settings"; sent with the venue to screens and previews; several badges per product (MenuList.badges lists, a single one still read) in the shared multiple Dropdown; a board's badge colour / text colour override them (None = each own). - Widgets: colour, background plate, font, bold / italic / underline, text size, QR colours; widgets in a stack's part get every setting, vertical alignment, and a custom box inside their place, picked (stack, then widget) and dragged on the preview (selection by path "2.1.0"). - Menu slides: vertical alignment of the list (board_valign); "Where the list sits" is now "Horizontal alignment". - Message of the day: one component in the settings tab, on the Overview and from its widget. - Leaving a slide with changes: "Save and leave" (ConfirmDialog altLabel). - @xenia/ui: ColourField (with colour.js helpers), FieldRow (framed only while wrapped), Slider, IconPicker, Segmented multiple; native selects on the Overview and signage replaced by Dropdown, the device settings' colour input by ColourField. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.7 KiB
React
37 lines
1.7 KiB
React
// The message of the day (plan step 5.6c; owner review 5, 2026-11-21: one editor, used in Signage →
|
|
// Message & settings, on the Overview and from a message widget): every screen shows it at once.
|
|
import { useEffect, useState } from 'react'
|
|
import toast from 'react-hot-toast'
|
|
import { errorMessage } from '@xenia/api'
|
|
import { useTranslation } from '@xenia/i18n'
|
|
import { Button, Input, Spinner } from '@xenia/ui'
|
|
import * as api from './signageApi'
|
|
|
|
export default function MessageOfTheDay({ onSaved, testId = 'signage-message' }) {
|
|
const { t } = useTranslation('manager')
|
|
const [text, setText] = useState(null)
|
|
const [saved, setSaved] = useState('')
|
|
const [busy, setBusy] = useState(false)
|
|
useEffect(() => {
|
|
api.getMessage().then(m => { setText(m.text || ''); setSaved(m.text || '') }).catch(err => toast.error(errorMessage(err, t)))
|
|
}, [t])
|
|
if (text === null) return <div className="flex justify-center p-3"><Spinner /></div>
|
|
const save = async () => {
|
|
setBusy(true)
|
|
try {
|
|
const r = await api.putMessage(text.trim())
|
|
setSaved(r.text || ''); setText(r.text || '')
|
|
toast.success(t('settings.saved'))
|
|
onSaved?.(r.text || '')
|
|
} catch (err) { toast.error(errorMessage(err, t)) }
|
|
setBusy(false)
|
|
}
|
|
return (
|
|
<div className="flex gap-2 items-start">
|
|
<Input value={text} maxLength={200} onChange={e => setText(e.target.value)} className="flex-1" placeholder={t('signage.settings.messagePlaceholder')}
|
|
aria-label={t('signage.settings.message')} data-testid={testId} onKeyDown={e => { if (e.key === 'Enter' && text.trim() !== saved.trim()) save() }} />
|
|
<Button loading={busy} disabled={text.trim() === saved.trim()} onClick={save} data-testid={`${testId}-save`}>{t('fees.save')}</Button>
|
|
</div>
|
|
)
|
|
}
|