feat: printing problems shown and handled; printing set-up on v2 (platform-v2 step 6.10)

- a ticket that doesn't print is a problem for whoever sent it and the managers:
  GET /api/print-problems (the order, table, dishes, printer, since when, tries,
  last error, who sent it) and three ways out: print again, send to another
  printer, handled (services/print_problems.py; print_jobs.resolved_by /
  redirected_to, Alembic 0036); live event print.problems from the print paths
- phone: the red printer button opens the problems sheet, the table page warns
  (usePrintProblems replaces the 8 s poll); counter POS: a red button under the
  modes with the shared panel (@xenia/ordering PrintProblemsPanel + pure rules);
  manager: a card on the overview (top), the Tables page and the order page
- manager: Settings -> Printing (printers with reachability, test print, network
  scan; ticket layout + test ticket, beep, fonts with previews, dot leader,
  dividers) and Management -> Prep zones (cards + zone dialog with the ticket
  language, printers, copies, sorting, category order, kitchen screen) rebuilt in
  src/pages/printing; v1 PrintFontsTab, PrepZonesConfigPage, PendingPrints and
  /api/orders/pending-prints removed
- access: printer add/edit/delete/scan need core.settings.manage, prep zone
  changes catalog.menu.manage (were any dashboard user)
- tests: test_print_problems.py, @xenia/ordering printProblems, manager
  printing.test.mjs, e2e print_problems.mjs (done-when) + manager.mjs printing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 01:40:07 +02:00
co-authored by Claude Opus 5.5
parent 070c9cf625
commit f31bdf42aa
57 changed files with 2557 additions and 2221 deletions
+2
View File
@@ -22,6 +22,7 @@ import { addLine, categoriesWithProducts, forSalesPoint, salesPointFor, defaultS
import { findOnline, ONLINE_LISTS } from './logic/online'
import { BOOKING_LIST, findBooking } from './logic/bookings'
import BookingPanel from './BookingPanel'
import PrintProblems from './PrintProblems'
import CallPopup from './CallPopup'
import { isFresh } from './logic/calls'
import BookingsView from './BookingsView'
@@ -145,6 +146,7 @@ function Counter({ menu, t }) {
)}
<ModeButton active={mode === 'receipts'} onClick={() => setMode('receipts')} icon={Receipt} testId="mode-receipts">{t('pos.mode.receipts')}</ModeButton>
</div>
<PrintProblems onOpenTable={id => { setMode('tables'); setTableId(id); setTableCart([]) }} />
<div className="flex-1 overflow-y-auto p-2 grid content-start gap-1"
data-testid={mode === 'online' ? 'online-lists' : mode === 'receipts' ? 'receipt-scopes' : picking ? 'pos-zones' : 'pos-categories'}>
{mode === 'receipts' ? (
+58
View File
@@ -0,0 +1,58 @@
// Tickets that didn't print, at the counter (plan step 6.10): a red button under the modes
// while any waits ("2 tickets didn't print"), opening the shared panel: print again, send to
// another printer, or handled. A new problem plays the chime once.
import { useEffect, useRef, useState } from 'react'
import { Printer } from 'lucide-react'
import { PrintProblemsPanel, actionRequest } from '@xenia/ordering'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, useToast } from '@xenia/ui'
import client from '../../api/client'
import { playChime } from './chime'
import { usePrintProblems } from './usePos'
export default function PrintProblems({ onOpenTable }) {
const { t } = useTranslation('common')
const toast = useToast()
const { data, reload } = usePrintProblems()
const [open, setOpen] = useState(false)
const known = useRef(null) // job ids already seen (null: first load, no chime)
const problems = data?.problems ?? []
const ids = problems.map(p => p.job_id).join(',')
// a ticket the counter hasn't seen fail yet: one chime
useEffect(() => {
if (!data) return
const now = ids ? ids.split(',') : []
if (known.current && now.some(id => !known.current.has(id))) playChime()
known.current = new Set(now)
}, [ids, data])
if (!problems.length) return null
async function run(kind, problem, printerId) {
const [url, body] = actionRequest(kind, problem, printerId)
const { data: res } = await client.post(url, body, { xenia: { noOverride: true } })
if (kind === 'retry' && !res.ok) toast.error(t('printProblems.stillNot', { printer: res.printer }))
else toast.success(t(`printProblems.done.${kind}`, { printer: res.printer }))
reload()
}
return (
<>
<div className="p-2 border-b border-line">
<Button variant="danger" block icon={<Printer size={16} />} onClick={() => setOpen(true)} data-testid="pos-print-problems">
{t('printProblems.count', { count: problems.length })}
</Button>
</div>
{open && (
<Dialog open size="lg" onClose={() => setOpen(false)} title={t('printProblems.title')}
footer={<Button variant="secondary" onClick={() => setOpen(false)}>{t('printProblems.close')}</Button>}>
<div className="-mx-4">
<PrintProblemsPanel problems={problems} printers={data?.printers ?? []} run={run}
onOpen={p => { if (p.table_id != null) { setOpen(false); onOpenTable(p.table_id) } }} />
</div>
</Dialog>
)}
</>
)
}
+14 -1
View File
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { useModule } from '@xenia/access'
import client from '../../api/client'
import { useLiveEvent, useLiveEvents } from '../../device/context'
import { useQuote as useSharedQuote } from '@xenia/ordering'
import { PRINT_EVENT, useQuote as useSharedQuote } from '@xenia/ordering'
const quiet = { xenia: { noOverride: true } }
const MENU_REFRESH_MS = 5 * 60_000 // prices can change with the time (happy hours)
@@ -77,6 +77,19 @@ export function useTables() {
return { data, reload: load }
}
/** Tickets that didn't print (6.10): GET /api/print-problems → { problems, printers }; live. */
export function usePrintProblems() {
const [data, setData] = useState(null)
const load = useCallback(async () => {
try { setData((await client.get('/api/print-problems', quiet)).data) } catch { /* the shell shows offline */ }
}, [])
const soon = useCoalesced(load)
useEffect(() => { load() }, [load])
useLiveEvent('ready', load)
useLiveEvents([PRINT_EVENT, 'order_closed'], soon)
return { data, reload: load }
}
/** The table map (6.8): GET /api/floor-plans/live, reloaded on the tables' events and plan changes. */
export function useFloorLive() {
const [data, setData] = useState(null)