mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 19:51:23 +00:00
fix to category search
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React, { FC } from 'react'
|
||||
import React, { FC, useEffect } from 'react'
|
||||
import Search from '@components/search'
|
||||
import { ModuleWithInit } from '@agility/nextjs'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
interface ICustomData {
|
||||
categories: any
|
||||
|
@@ -95,13 +95,16 @@ const Layout: FC<Props> = (props) => {
|
||||
|
||||
const {
|
||||
children,
|
||||
pageProps: { agilityProps, categories = [], ...pageProps },
|
||||
pageProps: { agilityProps, ...pageProps },
|
||||
} = props
|
||||
|
||||
|
||||
const { acceptedCookies, onAcceptCookies } = useAcceptCookies()
|
||||
const { locale = 'en-US' } = useRouter()
|
||||
const navBarlinks = categories.slice(0, 2).map((c) => ({
|
||||
|
||||
const categories = agilityProps?.globalData?.sitedata?.categoryLinks || []
|
||||
|
||||
const navBarlinks = categories.slice(0, 2).map((c:any) => ({
|
||||
label: c.name,
|
||||
href: `/search/${c.slug}`,
|
||||
}))
|
||||
|
@@ -42,10 +42,13 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
||||
|
||||
const { pathname, category, brand } = useSearchMeta(asPath)
|
||||
const activeCategory = categories.find((cat: any) => cat.slug === category)
|
||||
|
||||
|
||||
const activeBrand = brands.find(
|
||||
(b: any) => getSlug(b.node.path) === `brands/${brand}`
|
||||
)?.node
|
||||
|
||||
|
||||
const { data } = useSearch({
|
||||
search: typeof q === 'string' ? q : '',
|
||||
categoryId: activeCategory?.id,
|
||||
|
Reference in New Issue
Block a user