Add refusals tab to the order dashboard

Orders whose Nova Poshta status is a refusal (102/103/105/108) now show
only under «Отказы», whether or not they have a receipt. GET /orders takes
tab=no_receipt|has_receipt|refused instead of has_receipt. NP statuses are
also polled for orders that already have a receipt, until NP reports a
final status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 21:25:59 +03:00
co-authored by Claude Opus 5.5
parent 56ac0fc370
commit f88b5cccc0
9 changed files with 116 additions and 33 deletions
+3
View File
@@ -5,6 +5,9 @@
import type { ReceiptStatus } from '@/features/receipts/types'
/** Вкладка дашборда (`OrderTab` в backend/app/services/orders.py). */
export type OrderTab = 'no_receipt' | 'has_receipt' | 'refused'
export interface OrderGood {
id: string
sku: string
+5 -4
View File
@@ -1,18 +1,19 @@
import { useQuery } from '@tanstack/react-query'
import { getOrders } from '@/api/orders'
import type { OrderTab } from '@/features/orders/types'
/** Пока чек отправляется в Checkbox — опрашиваем часто, иначе статусы чеков обновляет worker раз в минуту. */
const PENDING_POLL_MS = 3_000
const RECEIPTS_POLL_MS = 30_000
export function useOrders(hasReceipt: boolean) {
export function useOrders(tab: OrderTab) {
return useQuery({
queryKey: ['orders', hasReceipt],
queryFn: () => getOrders(hasReceipt),
queryKey: ['orders', tab],
queryFn: () => getOrders(tab),
refetchInterval: (query) => {
if (query.state.data?.some((order) => order.receipt_status === 'pending')) return PENDING_POLL_MS
return hasReceipt ? RECEIPTS_POLL_MS : false
return tab === 'has_receipt' ? RECEIPTS_POLL_MS : false
},
})
}