mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
✨ feat: get all facets
:%s
This commit is contained in:
3
src/components/hooks/facets/index.ts
Normal file
3
src/components/hooks/facets/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { default as useFacets } from './useFacets'
|
||||
|
||||
|
12
src/components/hooks/facets/useFacets.tsx
Normal file
12
src/components/hooks/facets/useFacets.tsx
Normal 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
|
Reference in New Issue
Block a user