From a1d1fcdd4300ee65d7ead306581091cfea2d59e8 Mon Sep 17 00:00:00 2001 From: Veronika Smirnova Date: Mon, 28 Jul 2025 10:50:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=20=D1=83?= =?UTF-8?q?=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=BE=D0=B2=D1=8B=D1=85=20=D0=B7=D0=B0=D1=8F?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=D1=85=20=D0=BD=D0=B0=20=D1=83=D0=B2=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=BF=D1=80=D0=B8=D0=BD=D1=8F=D1=82=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BA=D0=B0=D1=85.=20?= =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=20GraphQL=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B0=20=D0=BE?= =?UTF-8?q?=D0=B6=D0=B8=D0=B4=D0=B0=D1=8E=D1=89=D0=B8=D1=85=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=B2=D0=BE=D0=BA.=20=D0=9E=D0=BF=D1=82?= =?UTF-8?q?=D0=B8=D0=BC=D0=B8=D0=B7=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=83?= =?UTF-8?q?=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=B2=20=D0=B1=D0=BE=D0=BA=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/dashboard/sidebar.tsx | 45 ++++++++++++---------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/components/dashboard/sidebar.tsx b/src/components/dashboard/sidebar.tsx index b39eb73..b0bc31d 100644 --- a/src/components/dashboard/sidebar.tsx +++ b/src/components/dashboard/sidebar.tsx @@ -10,7 +10,7 @@ import { useQuery } from "@apollo/client"; import { GET_CONVERSATIONS, GET_INCOMING_REQUESTS, - GET_SUPPLY_ORDERS, + GET_PENDING_SUPPLIES_COUNT, } from "@/graphql/queries"; import { Settings, @@ -27,32 +27,21 @@ import { BarChart3, } from "lucide-react"; -// Компонент для отображения уведомлений о новых заявках -function NewOrdersNotification() { - const { user } = useAuth(); - - // Загружаем заказы поставок для поставщика - const { data: ordersData } = useQuery(GET_SUPPLY_ORDERS, { - pollInterval: 30000, // Обновляем каждые 30 секунд для заявок +// Компонент для отображения уведомлений о непринятых поставках +function PendingSuppliesNotification() { + const { data: pendingData } = useQuery(GET_PENDING_SUPPLIES_COUNT, { + pollInterval: 30000, // Обновляем каждые 30 секунд fetchPolicy: "cache-first", errorPolicy: "ignore", - skip: user?.organization?.type !== "WHOLESALE", }); - if (user?.organization?.type !== "WHOLESALE") return null; + const pendingCount = pendingData?.pendingSuppliesCount?.total || 0; - const orders = ordersData?.supplyOrders || []; - // Считаем заявки в статусе PENDING (ожидают одобрения поставщика) - const pendingOrders = orders.filter( - (order) => - order.status === "PENDING" && order.partnerId === user?.organization?.id - ); - - if (pendingOrders.length === 0) return null; + if (pendingCount === 0) return null; return (
- {pendingOrders.length > 99 ? "99+" : pendingOrders.length} + {pendingCount > 99 ? "99+" : pendingCount}
); } @@ -447,12 +436,14 @@ export function Sidebar() { isSuppliesActive ? "bg-white/20 text-white hover:bg-white/30" : "text-white/80 hover:bg-white/10 hover:text-white" - } cursor-pointer`} + } cursor-pointer relative`} onClick={handleSuppliesClick} title={isCollapsed ? "Мои поставки" : ""} > {!isCollapsed && Мои поставки} + {/* Уведомление о непринятых поставках */} + )} @@ -504,7 +495,7 @@ export function Sidebar() { isSuppliesActive ? "bg-white/20 text-white hover:bg-white/30" : "text-white/80 hover:bg-white/10 hover:text-white" - } cursor-pointer`} + } cursor-pointer relative`} onClick={handleSuppliesClick} title={isCollapsed ? "Входящие поставки" : ""} > @@ -512,6 +503,8 @@ export function Sidebar() { {!isCollapsed && ( Входящие поставки )} + {/* Уведомление о непринятых поставках */} + )} @@ -569,10 +562,8 @@ export function Sidebar() { > {!isCollapsed && Заявки} - {/* Уведомление о новых заявках */} - {user?.organization?.type === "WHOLESALE" && ( - - )} + {/* Уведомление о непринятых поставках */} + )} @@ -586,12 +577,14 @@ export function Sidebar() { isSuppliesActive ? "bg-white/20 text-white hover:bg-white/30" : "text-white/80 hover:bg-white/10 hover:text-white" - } cursor-pointer`} + } cursor-pointer relative`} onClick={handleSuppliesClick} title={isCollapsed ? "Перевозки" : ""} > {!isCollapsed && Перевозки} + {/* Уведомление о непринятых поставках */} + )}