diff options
Diffstat (limited to 'src/pages/shop')
| -rw-r--r-- | src/pages/shop/brands/[slug].jsx | 6 | ||||
| -rw-r--r-- | src/pages/shop/product/variant/[slug].jsx | 10 |
2 files changed, 11 insertions, 5 deletions
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, ' ') |
