feat(realtime): implement SSE realtime notifications; publish events from resolvers; remove polling in chat/sidebar/supplies/warehouse and wire realtime refetch

This commit is contained in:
Bivekich
2025-08-11 22:13:33 +03:00
parent 52107e793e
commit 3a56092385
14 changed files with 562 additions and 40 deletions

View File

@ -46,6 +46,7 @@ import {
} from '@/graphql/queries'
import { useAuth } from '@/hooks/useAuth'
import { useSidebar } from '@/hooks/useSidebar'
import { useRealtime } from '@/hooks/useRealtime'
import { WbReturnClaims } from './wb-return-claims'
@ -238,7 +239,26 @@ export function FulfillmentWarehouseDashboard() {
refetch: refetchWarehouseStats,
} = useQuery(GET_FULFILLMENT_WAREHOUSE_STATS, {
fetchPolicy: 'no-cache', // Принудительно обходим кеш
pollInterval: 60000, // Обновляем каждую минуту
})
// Real-time: обновляем ключевые блоки при событиях поставок/склада
useRealtime({
onEvent: (evt) => {
switch (evt.type) {
case 'supply-order:new':
case 'supply-order:updated':
refetchOrders()
refetchWarehouseStats()
refetchProducts()
refetchSellerSupplies()
refetchFulfillmentSupplies()
break
case 'warehouse:changed':
refetchWarehouseStats()
refetchFulfillmentSupplies()
break
}
},
})
// Логируем статистику склада для отладки