From ca30c28dd0b19977eb771fc32ff5e520cdef1068 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 3 Oct 2024 16:47:37 +0700 Subject: product varian --- .../components/Product/ProductDesktopVariant.jsx | 185 +++++++++++---------- src/pages/api/shop/variant-detail.js | 2 +- src/pages/shop/product/variant/[slug].jsx | 7 - src/utils/solrMapping.js | 1 + 4 files changed, 103 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 2f2caa56..55effdfb 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -18,10 +18,13 @@ import currencyFormat from '@/core/utils/currencyFormat'; import { createSlug } from '@/core/utils/slug'; import whatsappUrl from '@/core/utils/whatsappUrl'; +import { RWebShare } from 'react-web-share'; import productSimilarApi from '../../api/productSimilarApi'; import ProductCard from '../ProductCard'; import ProductSimilar from '../ProductSimilar'; -import { RWebShare } from 'react-web-share'; +import ProductPromoSection from '~/modules/product-promo/components/Section'; + +const SELF_HOST = process.env.NEXT_PUBLIC_SELF_HOST; const ProductDesktopVariant = ({ product, @@ -44,11 +47,18 @@ const ProductDesktopVariant = ({ const [quantityInput, setQuantityInput] = useState(1); + const createdAskUrl = whatsappUrl({ + template: 'product', + payload: { + manufacture: product.manufacture.name, + productName: product.name, + url: process.env.NEXT_PUBLIC_SELF_HOST + router.asPath, + }, + fallbackUrl: router.asPath, + }); + const getLowestPrice = useCallback(() => { const lowest = product.price; - /* const lowest = prices.reduce((lowest, price) => { - return price.priceDiscount < lowest.priceDiscount ? price : lowest - }, prices[0])*/ return lowest; }, [product]); @@ -81,7 +91,7 @@ const ProductDesktopVariant = ({ router.push(`/login?next=/shop/product/${slug}`); return; } - const quantity = variantQuantityRefs.current[product.id].value; + const quantity = quantityInput; if (!validQuantity(quantity)) return; updateItemCart({ productId: product.id, @@ -96,7 +106,7 @@ const ProductDesktopVariant = ({ }; const handleBuy = (variant) => { - const quantity = variantQuantityRefs.current[product.id].value; + const quantity = quantityInput; if (!validQuantity(quantity)) return; updateItemCart({ @@ -177,71 +187,26 @@ const ProductDesktopVariant = ({
Item Code
{product.code}
-
+
Manufacture
- {product.manufacture?.name ? ( - - {product.manufacture?.name} - - ) : ( -
-
- )} -
-
- -
-
- Persiapan Barang -
-
- {!product?.sla && } - {product?.sla && ( - - - {product?.sla?.slaDate} - - - - )} + + {product.manufacture.name} +
- {/*
-
Stock
-
- {!product?.sla && } - {product?.sla?.qty > 0 && {product?.sla?.qty}} - {product?.sla?.qty == 0 && ( - - Tanya Admin - - )} -
-
*/} - -
+
Berat Barang
{product?.weight > 0 && {product?.weight} KG} @@ -263,24 +228,52 @@ const ProductDesktopVariant = ({ )}
+
+
Terjual
+
-
+
+ +
+
+ Persiapan Barang +
+
+ {!product?.sla && } + {product?.sla && ( + + + {product?.sla?.slaDate} + + + + )} +
+
-
-

- Informasi Produk -

-
-

' - ? 'Belum ada deskripsi' - : product.parent.description, - }} - /> +
+ + +
+

+ Informasi Produk +

+
+

' + ? 'Belum ada deskripsi' + : product.parent.description, + }} + /> +
@@ -341,7 +334,7 @@ const ProductDesktopVariant = ({ )} )} -
+
+
+ + {' '} + Stock : {product?.sla?.qty}{' '} + +
+
+ {product?.sla?.qty > 0 && ( + + pickup now + + )} +
-
+
-
+