feat: fire cartAdded event in AddToCartButton

This commit is contained in:
Kirill
2026-05-25 17:48:55 +05:00
parent 45aee539a2
commit d87abb6425
@@ -4,6 +4,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useUnit } from 'effector-react'
import { addToCart } from '@/entities/cart/api/cart-api'
import { $user } from '@/shared/model/auth'
import { cartAdded } from '@/shared/model/cart-notifications'
type Props = {
productId: string
@@ -18,7 +19,10 @@ export function AddToCartButton(props: Props) {
const addMut = useMutation({
mutationFn: () => addToCart({ productId, qty }),
onSuccess: () => void qc.invalidateQueries({ queryKey: ['me', 'cart'] }),
onSuccess: () => {
void qc.invalidateQueries({ queryKey: ['me', 'cart'] })
cartAdded()
},
})
return (