feat: fire cartAdded event in ToggleCartIcon add mutation

This commit is contained in:
Kirill
2026-05-25 17:56:45 +05:00
parent d87abb6425
commit c9e3917129
@@ -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({