4
0
forked from crowetic/commerce

Fix bigcommerce brands (#837)

This commit is contained in:
Catalin Pinte 2022-10-06 17:08:58 +03:00 committed by GitHub
parent 6c2610584d
commit 990bdf1e6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -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}`,
}
}

View File

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

View File

@ -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,
})