summaryrefslogtreecommitdiff
path: root/src/lib/wishlist/hooks/useWishlists.js
blob: a219ab69d0669f01bab6ccd8e41e4f78e03810da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { useQuery } from "react-query"
import wishlistsApi from "../api/wishlistsApi"

const useWishlists = ({ page, limit }) => {
  const offset = (page - 1) * limit
  const fetchWishlists = async () => await wishlistsApi({ limit, offset })
  const { data, isLoading } = useQuery(`wishlists-${limit}-${offset}`, fetchWishlists)

  return {
    wishlists: { data, isLoading }
  }
}

export default useWishlists