From 7892008931b6c2e4c0f220212aa51b489d79dc86 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 7 Mar 2024 14:51:12 +0700 Subject: add information product in page variant detail --- .../components/Product/ProductDesktopVariant.jsx | 49 +++++++--------------- src/pages/api/shop/variant-detail.js | 5 ++- src/utils/solrMapping.js | 7 ++-- 3 files changed, 22 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index bae00b87..09b30a44 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -1,3 +1,4 @@ + import { Box, Skeleton, Tooltip } from '@chakra-ui/react'; import { HeartIcon } from '@heroicons/react/24/outline'; import { Info } from 'lucide-react'; @@ -264,41 +265,19 @@ const ProductDesktopVariant = ({ - {/*
-
-
Informasi Produk
-
- {informationTabOptions.map((option) => ( - setInformationTab(option.value)} - > - {option.label} - - ))} -
-
-
- - - - - - Belum ada informasi. - -
-
-
-
*/} +
+

Informasi Produk

+
+

' + ? 'Belum ada deskripsi' + : product.parent.description, + }} + /> +
{product?.isFlashsale > 0 && diff --git a/src/pages/api/shop/variant-detail.js b/src/pages/api/shop/variant-detail.js index fadbe000..08ce75b8 100644 --- a/src/pages/api/shop/variant-detail.js +++ b/src/pages/api/shop/variant-detail.js @@ -8,7 +8,10 @@ export default async function handler(req, res) { `/solr/variants/select?q=id:${req.query.id}&q.op=OR&indent=true` ) let auth = req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth - let result = variantsMappingSolr('',productVariants.data.response.docs, auth || false) + let productTemplate = await axios( + process.env.SOLR_HOST + `/solr/product/select?q=id:${req.query.id}&q.op=OR&indent=true` + ) + let result = variantsMappingSolr(productTemplate.data.response.docs, productVariants.data.response.docs, auth || false) res.status(200).json(result) } catch (error) { diff --git a/src/utils/solrMapping.js b/src/utils/solrMapping.js index 7e887253..8877d19f 100644 --- a/src/utils/solrMapping.js +++ b/src/utils/solrMapping.js @@ -98,9 +98,10 @@ export const variantsMappingSolr = (parent, products, pricelist) => { }; } productMapped.parent = { - id: parent.product_id_i || '', - image: parent.image_s || '', - name: parent.name_s || '', + id: parent[0].product_id_i || '', + image: parent[0].image_s || '', + name: parent[0].name_s || '', + description: parent[0].description_t || '', }; return productMapped; }); -- cgit v1.2.3