mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
12 lines
523 B
TypeScript
12 lines
523 B
TypeScript
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)
|
|
return { facets: data?.facets.items, totalItems: data?.facets.totalItems, loading: isValidating, ...rest }
|
|
}
|
|
|
|
export default useFacets
|