// Tickets that didn't print, on the phone (plan step 6.10): opened from the red printer button // in the header (all of them) or from a table's warning (that order's). Each says where it // belongs, which printer, since when and what's on it; then Print again, Send to another // printer, or Handled (told the kitchen by voice). The list comes back over the live event. import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { useFormat, useTranslation } from '@xenia/i18n' import { actionRequest, itemsText, otherPrinters, placeOf } from '@xenia/ordering/printProblems' import client from '../api/client' import { apiError } from '../api/errors' export default function PrintProblemsSheet({ problems, printers, onClose, onChanged, showPlace = true }) { const { t } = useTranslation('common') return (
e.stopPropagation()} data-testid="print-problems-sheet">

{t('printProblems.title')}

{problems.length === 0 &&

{t('printProblems.none')}

} {problems.map(p => )}
) } function Problem({ problem: p, printers, onChanged, showPlace, onClose }) { const { t } = useTranslation('common') const { formatTime } = useFormat() const navigate = useNavigate() const others = otherPrinters(p, printers) const [to, setTo] = useState(others[0] ? String(others[0].id) : '') const [busy, setBusy] = useState(null) const [note, setNote] = useState(null) // { ok, text } async function act(kind, printerId) { setBusy(kind) setNote(null) try { const [url, body] = actionRequest(kind, p, printerId) const { data } = await client.post(url, body) if (kind === 'retry' && !data.ok) setNote({ ok: false, text: t('printProblems.stillNot', { printer: data.printer }) }) onChanged() } catch (err) { setNote({ ok: false, text: apiError(err, t('printProblems.failed')) }) } finally { setBusy(null) } } return (
{showPlace && ( )} 🖨 {t('printProblems.notOn', { printer: p.printer.name })}
{t('printProblems.since', { time: formatTime(p.since) })} · {t('printProblems.tries', { count: p.attempts })}
{itemsText(p)}
{others.length > 0 && (
)}
{t('printProblems.handledHint')}
{note &&

{note.text}

}
) }