Snapshot of in-progress work across local_backend, manager_dashboard, and waiter_pwa (pricing, chat, fiscal, prep zones, recovery codes, CRM, inventory, permissions), plus the nginx/docker-compose deploy fixes for the Unraid + NPM reverse-proxy setup. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
30 lines
704 B
JavaScript
30 lines
704 B
JavaScript
import { useState, useEffect } from 'react'
|
|
import client from '../api/client'
|
|
|
|
// Polls /api/orders/pending-prints every 8s and returns the count of pending print jobs.
|
|
export default function useFailedPrintCount() {
|
|
const [count, setCount] = useState(0)
|
|
|
|
useEffect(() => {
|
|
let cancelled = false
|
|
|
|
async function refresh() {
|
|
try {
|
|
const res = await client.get('/api/orders/pending-prints')
|
|
if (!cancelled) setCount(res.data?.count ?? 0)
|
|
} catch {
|
|
// Network error — leave count as-is
|
|
}
|
|
}
|
|
|
|
refresh()
|
|
const id = setInterval(refresh, 8000)
|
|
return () => {
|
|
cancelled = true
|
|
clearInterval(id)
|
|
}
|
|
}, [])
|
|
|
|
return count
|
|
}
|