feat: fire cartAdded event in ToggleCartIcon add mutation
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user