fix to category search

This commit is contained in:
Joel Varty
2021-06-22 17:12:31 -04:00
parent 3114388069
commit 00227d8bf0
11 changed files with 50 additions and 12 deletions

View File

@@ -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],

View File

@@ -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()