summaryrefslogtreecommitdiff
path: root/src/lib/wishlist/hooks/useWishlist.js
blob: 8580a19dfcf449d3d3066ae13e48c2d480c1f40a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { useQuery } from 'react-query'
import wishlistApi from '../api/wishlistApi'

const useWishlist = ({ productId }) => {
  const fetchWishlist = async () => await wishlistApi({ productId })
  const { data, isLoading, refetch } = useQuery(`wishlist-${productId}`, fetchWishlist)

  return {
    wishlist: { data, isLoading, refetch }
  }
}

export default useWishlist