feat: fire cartAdded event in AddToCartButton
This commit is contained in:
@@ -4,6 +4,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|||||||
import { useUnit } from 'effector-react'
|
import { useUnit } from 'effector-react'
|
||||||
import { addToCart } from '@/entities/cart/api/cart-api'
|
import { addToCart } from '@/entities/cart/api/cart-api'
|
||||||
import { $user } from '@/shared/model/auth'
|
import { $user } from '@/shared/model/auth'
|
||||||
|
import { cartAdded } from '@/shared/model/cart-notifications'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
productId: string
|
productId: string
|
||||||
@@ -18,7 +19,10 @@ export function AddToCartButton(props: Props) {
|
|||||||
|
|
||||||
const addMut = useMutation({
|
const addMut = useMutation({
|
||||||
mutationFn: () => addToCart({ productId, qty }),
|
mutationFn: () => addToCart({ productId, qty }),
|
||||||
onSuccess: () => void qc.invalidateQueries({ queryKey: ['me', 'cart'] }),
|
onSuccess: () => {
|
||||||
|
void qc.invalidateQueries({ queryKey: ['me', 'cart'] })
|
||||||
|
cartAdded()
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user