Fetch Spree Categories and Brands

This commit is contained in:
tniezg
2021-07-28 15:57:37 +02:00
parent c546d26bbe
commit 2209731d72
4 changed files with 113 additions and 40 deletions

View File

@@ -23,15 +23,16 @@ export const handler: SWRHook<SearchProductsHook> = {
options
)
const categoryOrBrandId = input.categoryId || input.brandId
const taxons = [input.categoryId, input.brandId].filter(Boolean)
const filter = categoryOrBrandId
? {
filter: {
taxons: categoryOrBrandId,
},
}
: {}
const filter =
taxons.length > 0
? {
filter: {
taxons: taxons.join(','),
},
}
: {}
const { data: spreeSuccessResponse } = await fetch<
GraphQLFetcherResult<IProducts>
@@ -81,15 +82,6 @@ export const handler: SWRHook<SearchProductsHook> = {
},
})
},
// (input = {}) => {
// return {
// data: {
// // FIXME: Use actual fetcher
// products: [],
// },
// }
// },
}
export default useSearch as UseSearch<typeof handler>