From 7f2a0d903aa76f0317e376b36fbb999a75c691a2 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Fri, 28 May 2021 12:56:50 -0500 Subject: [PATCH] Fixes in search hook --- framework/bigcommerce/product/use-search.tsx | 4 ++-- framework/commerce/types/product.ts | 13 +++++-------- pages/search.tsx | 1 - 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/framework/bigcommerce/product/use-search.tsx b/framework/bigcommerce/product/use-search.tsx index c9ac8f9a0..3c81d1171 100644 --- a/framework/bigcommerce/product/use-search.tsx +++ b/framework/bigcommerce/product/use-search.tsx @@ -22,9 +22,9 @@ export const handler: SWRHook = { if (search) url.searchParams.set('search', search) if (Number.isInteger(categoryId)) - url.searchParams.set('category', String(categoryId)) + url.searchParams.set('categoryId', String(categoryId)) if (Number.isInteger(brandId)) - url.searchParams.set('brand', String(brandId)) + url.searchParams.set('brandId', String(brandId)) if (sort) url.searchParams.set('sort', sort) return fetch({ diff --git a/framework/commerce/types/product.ts b/framework/commerce/types/product.ts index 782f2a31a..27e98598a 100644 --- a/framework/commerce/types/product.ts +++ b/framework/commerce/types/product.ts @@ -55,7 +55,10 @@ export type ProductTypes = { } export type SearchProductsHook = { - data: T['product'][] + data: { + products: T['product'][] + found: boolean + } body: T['searchBody'] input: T['searchBody'] fetcherInput: T['searchBody'] @@ -65,13 +68,7 @@ export type ProductsSchema = { endpoint: { options: {} handlers: { - getProducts: { - data: { - products: T['product'][] - found: boolean - } - body: SearchProductsHook['body'] - } + getProducts: SearchProductsHook } } } diff --git a/pages/search.tsx b/pages/search.tsx index 53452b74a..400217a26 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -18,7 +18,6 @@ import { getDesignerPath, useSearchMeta, } from '@lib/search' -import { Product } from '@commerce/types' // TODO(bc) Remove this. This should come from the API import getSlug from '@lib/get-slug'