mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 13:41:22 +00:00
Fixes in search hook
This commit is contained in:
parent
874cf9d5b3
commit
7f2a0d903a
@ -22,9 +22,9 @@ export const handler: SWRHook<SearchProductsHook> = {
|
|||||||
|
|
||||||
if (search) url.searchParams.set('search', search)
|
if (search) url.searchParams.set('search', search)
|
||||||
if (Number.isInteger(categoryId))
|
if (Number.isInteger(categoryId))
|
||||||
url.searchParams.set('category', String(categoryId))
|
url.searchParams.set('categoryId', String(categoryId))
|
||||||
if (Number.isInteger(brandId))
|
if (Number.isInteger(brandId))
|
||||||
url.searchParams.set('brand', String(brandId))
|
url.searchParams.set('brandId', String(brandId))
|
||||||
if (sort) url.searchParams.set('sort', sort)
|
if (sort) url.searchParams.set('sort', sort)
|
||||||
|
|
||||||
return fetch({
|
return fetch({
|
||||||
|
@ -55,7 +55,10 @@ export type ProductTypes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type SearchProductsHook<T extends ProductTypes = ProductTypes> = {
|
export type SearchProductsHook<T extends ProductTypes = ProductTypes> = {
|
||||||
data: T['product'][]
|
data: {
|
||||||
|
products: T['product'][]
|
||||||
|
found: boolean
|
||||||
|
}
|
||||||
body: T['searchBody']
|
body: T['searchBody']
|
||||||
input: T['searchBody']
|
input: T['searchBody']
|
||||||
fetcherInput: T['searchBody']
|
fetcherInput: T['searchBody']
|
||||||
@ -65,13 +68,7 @@ export type ProductsSchema<T extends ProductTypes = ProductTypes> = {
|
|||||||
endpoint: {
|
endpoint: {
|
||||||
options: {}
|
options: {}
|
||||||
handlers: {
|
handlers: {
|
||||||
getProducts: {
|
getProducts: SearchProductsHook<T>
|
||||||
data: {
|
|
||||||
products: T['product'][]
|
|
||||||
found: boolean
|
|
||||||
}
|
|
||||||
body: SearchProductsHook<T>['body']
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import {
|
|||||||
getDesignerPath,
|
getDesignerPath,
|
||||||
useSearchMeta,
|
useSearchMeta,
|
||||||
} from '@lib/search'
|
} from '@lib/search'
|
||||||
import { Product } from '@commerce/types'
|
|
||||||
|
|
||||||
// TODO(bc) Remove this. This should come from the API
|
// TODO(bc) Remove this. This should come from the API
|
||||||
import getSlug from '@lib/get-slug'
|
import getSlug from '@lib/get-slug'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user