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:
@@ -20,6 +20,7 @@ import AddItems from './AddItems'
|
||||
import OrderLines from './OrderLines'
|
||||
import OrderPeople from './OrderPeople'
|
||||
import PayDialog from './PayDialog'
|
||||
import PrintProblemsCard from './PrintProblemsCard'
|
||||
import { AuditList, PriceEventList } from './OrderHistory'
|
||||
import { closeStep, totals, unpaidIds, venueRules } from './orderLogic'
|
||||
|
||||
@@ -152,6 +153,8 @@ function OrderView({ orderId }) {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<PrintProblemsCard orderId={order.id} />
|
||||
|
||||
{tab === 'order' && (
|
||||
<div className={cx('grid gap-4 items-start', editable && 'lg:grid-cols-[minmax(0,1fr)_minmax(0,1.1fr)]')}>
|
||||
<div className="grid gap-4 min-w-0">
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Tickets that didn't print (plan step 6.10; replaces the overview's "waiting prints" card):
|
||||
// on the overview, the Tables page (all of them) and an order's page (its own). Live: the list
|
||||
// reloads on every `print.problems` event, so a ticket sent elsewhere or printed on a retry
|
||||
// leaves every screen at once. The bell still tells managers away from these pages (print.failing).
|
||||
import toast from 'react-hot-toast'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { PrintProblemsPanel, actionRequest, problemsOf } from '@xenia/ordering'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import client from '../../api/client'
|
||||
import { Card } from '../overview/parts'
|
||||
import { usePrintProblems } from './usePrintProblems'
|
||||
|
||||
export default function PrintProblemsCard({ orderId = null, onOpen }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const tc = useTranslation('common').t
|
||||
const qc = useQueryClient()
|
||||
const { data } = usePrintProblems()
|
||||
const all = data?.problems ?? []
|
||||
const shown = orderId == null ? all : problemsOf(all, orderId)
|
||||
if (!shown.length) return null
|
||||
|
||||
async function run(kind, problem, printerId) {
|
||||
const [url, body] = actionRequest(kind, problem, printerId)
|
||||
const { data: res } = await client.post(url, body)
|
||||
if (kind === 'retry' && !res.ok) toast.error(tc('printProblems.stillNot', { printer: res.printer }))
|
||||
else toast.success(tc(`printProblems.done.${kind}`, { printer: res.printer }))
|
||||
qc.invalidateQueries({ queryKey: ['print-problems'] })
|
||||
qc.invalidateQueries({ queryKey: ['orders-active'] })
|
||||
qc.invalidateQueries({ queryKey: ['order', problem.order_id] })
|
||||
}
|
||||
|
||||
return (
|
||||
<Card tone="danger" testId="print-problems-card"
|
||||
title={<span className="grid">
|
||||
<span>{tc('printProblems.title')}</span>
|
||||
<span className="text-label font-normal">{tc('printProblems.count', { count: shown.length })}</span>
|
||||
</span>}>
|
||||
<PrintProblemsPanel problems={shown} printers={data?.printers ?? []} run={run} showPlace={orderId == null}
|
||||
onOpen={onOpen ? p => onOpen(p.order_id, p.table_name) : undefined} />
|
||||
<p className="px-4 pb-3 text-caption text-ink-3">{t('orders.printHelp')}</p>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
// The tables now, in the manager (plan step 6.9; the map since 6.8): each table's state, total,
|
||||
// time open, waiters, flags and a booking kept for it soon (RESERVED). A table with an order
|
||||
// opens its order page; a free one opens a new order there. Quick actions set the table's flags
|
||||
// and can tell its waiters (or everyone) a message. Lines that didn't print are listed below.
|
||||
// and can tell its waiters (or everyone) a message. Tickets that didn't print are listed below
|
||||
// with what can be done about them (6.10).
|
||||
// Everything stays current through the live events.
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
@@ -14,7 +15,7 @@ import LiveFloor from '../floor/LiveFloor'
|
||||
import { useDuration } from '../overview/hooks'
|
||||
import { TABLE_STATES, durationParts, orderTotal, tableCards, tableName } from '../overview/overviewLogic'
|
||||
import { Money, Pill } from '../overview/parts'
|
||||
import PendingPrints from '../overview/PendingPrints'
|
||||
import PrintProblemsCard from './PrintProblemsCard'
|
||||
import { BORDER, SOFT, SOLID } from '../overview/tones'
|
||||
import QuickActions from './QuickActions'
|
||||
import { NO_ZONE, cardTarget, filterCards, flagsByTable, personName } from './orderLogic'
|
||||
@@ -94,7 +95,7 @@ export default function TablesPage() {
|
||||
</div>
|
||||
))}
|
||||
|
||||
<PendingPrints cards={cards.filter(c => c.pendingPrint)} onOpen={id => navigate(`/orders/${id}`)} />
|
||||
<PrintProblemsCard onOpen={id => navigate(`/orders/${id}`)} />
|
||||
|
||||
{quick && <QuickActions card={quick} flagDefs={flagDefs} current={flags[quick.table.id] ?? []} onClose={() => setQuick(null)} />}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// The tickets that didn't print (plan step 6.10): GET /api/print-problems → { problems, printers },
|
||||
// reloaded on the live event `print.problems` (and a closed order).
|
||||
import { PRINT_EVENT } from '@xenia/ordering'
|
||||
import client from '../../api/client'
|
||||
import { useLiveQuery } from '../../live/useLiveQuery'
|
||||
|
||||
export function usePrintProblems() {
|
||||
return useLiveQuery({
|
||||
queryKey: ['print-problems'],
|
||||
queryFn: () => client.get('/api/print-problems').then(r => r.data),
|
||||
events: [PRINT_EVENT, 'order_closed'],
|
||||
refetchInterval: 60_000,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user