From c9e3917129c7359eb8ab29e291739c4cf830130a Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 25 May 2026 17:56:45 +0500 Subject: [PATCH] feat: fire cartAdded event in ToggleCartIcon add mutation --- .../features/cart/toggle-cart-icon/ui/ToggleCartIcon.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/features/cart/toggle-cart-icon/ui/ToggleCartIcon.tsx b/client/src/features/cart/toggle-cart-icon/ui/ToggleCartIcon.tsx index fea5d09..af6ef01 100644 --- a/client/src/features/cart/toggle-cart-icon/ui/ToggleCartIcon.tsx +++ b/client/src/features/cart/toggle-cart-icon/ui/ToggleCartIcon.tsx @@ -6,6 +6,7 @@ import { ShoppingCart } from 'lucide-react' import { useNavigate } from 'react-router-dom' import { addToCart, fetchMyCart, removeCartItem } from '@/entities/cart/api/cart-api' import { $user } from '@/shared/model/auth' +import { cartAdded } from '@/shared/model/cart-notifications' export function ToggleCartIcon(props: { productId: string @@ -28,7 +29,10 @@ export function ToggleCartIcon(props: { const addMut = useMutation({ mutationFn: () => addToCart({ productId, qty: 1 }), - onSuccess: () => void qc.invalidateQueries({ queryKey: ['me', 'cart'] }), + onSuccess: () => { + void qc.invalidateQueries({ queryKey: ['me', 'cart'] }) + cartAdded() + }, }) const removeMut = useMutation({