// Signage → Message and weather (plan step 5.6c): the message of the day (one place for every // screen, at once) and the weather's town (picked from a search; the weather needs internet, and // without it the widget is simply hidden on the TVs). import { useCallback, useEffect, useState } from 'react' import toast from 'react-hot-toast' import { CloudOff, RefreshCw, Search } from 'lucide-react' import { errorMessage } from '@xenia/api' import { useFormat, useLanguage, useTranslation } from '@xenia/i18n' import { Button, Field, Input, Select, Spinner } from '@xenia/ui' import * as api from './signageApi' export default function SignageSettingsTab() { const { t } = useTranslation('manager') const { formatDateTime } = useFormat() const { language: lang } = useLanguage() const [message, setMessage] = useState(null) const [savedMessage, setSavedMessage] = useState('') const [status, setStatus] = useState(null) const [q, setQ] = useState('') const [places, setPlaces] = useState(null) const [units, setUnits] = useState('celsius') const [busy, setBusy] = useState(false) const load = useCallback(async () => { try { const [m, w] = await Promise.all([api.getMessage(), api.weatherStatus()]) setMessage(m.text || ''); setSavedMessage(m.text || ''); setStatus(w) if (w.place?.units) setUnits(w.place.units) } catch (err) { toast.error(errorMessage(err, t)) } }, [t]) useEffect(() => { load() }, [load]) const act = async (fn, done) => { setBusy(true) try { const r = await fn(); if (done) toast.success(done); return r } catch (err) { toast.error(errorMessage(err, t)); return null } finally { setBusy(false) } } if (message === null) return
{t('signage.settings.messageHint')}
{t('signage.settings.weatherHint')}
{status?.place ? ({t('signage.settings.noPlace')}
}{t('media.noMatch')}
: (