mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 19:51:23 +00:00
fix to category search
This commit is contained in:
@@ -21,9 +21,11 @@ export const handler: SWRHook<SearchProductsHook> = {
|
||||
// Use a dummy base as we only care about the relative path
|
||||
const url = new URL(options.url!, 'http://a')
|
||||
|
||||
const catID = parseInt(`${categoryId}`)
|
||||
|
||||
if (search) url.searchParams.set('search', search)
|
||||
if (Number.isInteger(categoryId))
|
||||
url.searchParams.set('categoryId', String(categoryId))
|
||||
if (Number.isInteger(catID))
|
||||
url.searchParams.set('categoryId', String(catID))
|
||||
if (Number.isInteger(brandId))
|
||||
url.searchParams.set('brandId', String(brandId))
|
||||
if (sort) url.searchParams.set('sort', sort)
|
||||
@@ -34,6 +36,7 @@ export const handler: SWRHook<SearchProductsHook> = {
|
||||
})
|
||||
},
|
||||
useHook: ({ useData }) => (input = {}) => {
|
||||
|
||||
return useData({
|
||||
input: [
|
||||
['search', input.search],
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Fetcher } from '@commerce/utils/types'
|
||||
|
||||
export const fetcher: Fetcher = async () => {
|
||||
console.log('FETCHER')
|
||||
|
||||
const res = await fetch('./data.json')
|
||||
if (res.ok) {
|
||||
const { data } = await res.json()
|
||||
|
Reference in New Issue
Block a user