forked from crowetic/commerce
Fix bigcommerce brands (#837)
This commit is contained in:
parent
6c2610584d
commit
990bdf1e6a
@ -139,10 +139,12 @@ export function normalizeCategory(category: BCCategory): Category {
|
||||
}
|
||||
|
||||
export function normalizeBrand(brand: BCBrand): Brand {
|
||||
const path = brand.node.path.replace('/brands/', '')
|
||||
const slug = getSlug(path)
|
||||
return {
|
||||
id: `${brand.node.entityId}`,
|
||||
name: brand.node.name,
|
||||
slug: getSlug(brand.node.path),
|
||||
path: brand.node.path,
|
||||
slug,
|
||||
path: `/${slug}`,
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ export default useSearch as UseSearch<typeof handler>
|
||||
|
||||
export type SearchProductsInput = {
|
||||
search?: string
|
||||
categoryId?: number | string
|
||||
brandId?: number
|
||||
categoryId?: string
|
||||
brandId?: string
|
||||
sort?: string
|
||||
locale?: string
|
||||
}
|
||||
@ -24,7 +24,7 @@ export const handler: SWRHook<SearchProductsHook> = {
|
||||
if (search) url.searchParams.set('search', search)
|
||||
if (Number.isInteger(Number(categoryId)))
|
||||
url.searchParams.set('categoryId', String(categoryId))
|
||||
if (Number.isInteger(brandId))
|
||||
if (Number.isInteger(Number(brandId)))
|
||||
url.searchParams.set('brandId', String(brandId))
|
||||
if (sort) url.searchParams.set('sort', sort)
|
||||
|
||||
|
@ -50,7 +50,7 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
||||
const { data, error } = useSearch({
|
||||
search: typeof q === 'string' ? q : '',
|
||||
categoryId: activeCategory?.id,
|
||||
brandId: (activeBrand as any)?.id,
|
||||
brandId: activeBrand?.id,
|
||||
sort: typeof sort === 'string' ? sort : '',
|
||||
locale,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user