summaryrefslogtreecommitdiff
path: root/src/lib/wishlist/hooks/useWishlists.js
blob: 169fdf46acf917a49f49444354415be65af4f692 (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