feat: get all facets

:%s
This commit is contained in:
lytrankieio123
2021-09-30 17:50:35 +07:00
parent 8a952c1d27
commit 5c70c8be25
6 changed files with 107 additions and 5 deletions

View File

@@ -0,0 +1,3 @@
export { default as useFacets } from './useFacets'

View File

@@ -0,0 +1,12 @@
import { GetAllFacetsQuery, QueryFacetsArgs } from '@framework/schema'
import { getAllFacetsQuery } from '@framework/utils/queries/get-all-facets-query'
import gglFetcher from 'src/utils/gglFetcher'
import useSWR from 'swr'
const useFacets = (options: QueryFacetsArgs) => {
const { data, isValidating, ...rest } = useSWR<GetAllFacetsQuery>([getAllFacetsQuery, options], gglFetcher)
console.log("here", data)
return { items: data?.facets.items, totalItems: data?.facets.totalItems, loading: isValidating, ...rest }
}
export default useFacets