diff options
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/api/shop/search.js | 2 | ||||
| -rw-r--r-- | src/pages/shop/brands/[slug].jsx | 6 | ||||
| -rw-r--r-- | src/pages/shop/product/variant/[slug].jsx | 10 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index b4d67c5d..883bb8df 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -67,7 +67,7 @@ export default async function handler(req, res) { } if (brand) parameter.push(`fq=manufacture_name:${brand.replace(/,/g, ' OR ')}`) - if (category) parameter.push(`fq=category_name:${category}`) + if (category) parameter.push(`fq=category_name:${category.replace(/,/g, ' OR ')}`) if (stock) parameter.push(`fq=stock_total_f:{1 TO *}`) // Single fq in url params diff --git a/src/pages/shop/brands/[slug].jsx b/src/pages/shop/brands/[slug].jsx index d75475b7..c3a7299f 100644 --- a/src/pages/shop/brands/[slug].jsx +++ b/src/pages/shop/brands/[slug].jsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router' import _ from 'lodash' import Seo from '@/core/components/Seo' import Breadcrumb from '@/lib/brand/components/Breadcrumb' +import useBrand from '@/lib/brand/hooks/useBrand' const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout')) const ProductSearch = dynamic(() => import('@/lib/product/components/ProductSearch')) @@ -14,6 +15,8 @@ export default function BrandDetail() { const { slug = '' } = router.query const brandName = getNameFromSlug(slug) + const id = getIdFromSlug(slug) + const {brand} = useBrand({id}) return ( <BasicLayout> <Seo @@ -29,12 +32,13 @@ export default function BrandDetail() { <Breadcrumb brandName={brandName} /> - <Brand id={getIdFromSlug(slug)} /> + <Brand brand={brand} /> {!_.isEmpty(router.query) && ( <ProductSearch query={_.omit(router.query, 'slug')} prefixUrl={`/shop/brands/${slug}`} defaultBrand={getNameFromSlug(slug)} + brand={brand} /> )} </BasicLayout> diff --git a/src/pages/shop/product/variant/[slug].jsx b/src/pages/shop/product/variant/[slug].jsx index 455b248b..401bce82 100644 --- a/src/pages/shop/product/variant/[slug].jsx +++ b/src/pages/shop/product/variant/[slug].jsx @@ -21,16 +21,18 @@ export async function getServerSideProps(context) { const tier = auth.pricelist ? auth.pricelist : false const authToken = auth?.token || '' - let response = await axios( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/variant-detail?id=` + getIdFromSlug(slug) +'&auth=' + tier + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/variant-detail?id=` + + getIdFromSlug(slug) + + '&auth=' + + tier ) let product = response.data // let product = await variantApi({ id: getIdFromSlug(slug), headers: { Token: authToken } }) - + if (product?.length == 1) { product = product[0] - /* const regexHtmlTags = /(<([^>]+)>)/gi + /* const regexHtmlTags = /(<([^>]+)>)/gi const regexHtmlTagsExceptP = /<\/?(?!p\b)[^>]*>/g product.description = product.description .replace(regexHtmlTagsExceptP, ' ') |
