From 3b19ddcd0051f094b4659a35107646d678c2fd0c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 14 Mar 2023 17:18:16 +0700 Subject: product detail --- src/lib/product/components/ProductDesktop.jsx | 160 ++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 src/lib/product/components/ProductDesktop.jsx (limited to 'src/lib/product/components/ProductDesktop.jsx') diff --git a/src/lib/product/components/ProductDesktop.jsx b/src/lib/product/components/ProductDesktop.jsx new file mode 100644 index 00000000..dc733eac --- /dev/null +++ b/src/lib/product/components/ProductDesktop.jsx @@ -0,0 +1,160 @@ +import Image from '@/core/components/elements/Image/Image' +import Link from '@/core/components/elements/Link/Link' +import DesktopView from '@/core/components/views/DesktopView' +import currencyFormat from '@/core/utils/currencyFormat' +import { HeartIcon } from '@heroicons/react/24/outline' +import { useEffect, useState } from 'react' + +const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { + const [variantQuantity, setVariantQuantity] = useState(null) + + useEffect(() => { + const mapVariantQuantity = product.variants.reduce((acc, cur) => { + acc[cur.id] = 1 + return acc + }, {}) + setVariantQuantity(mapVariantQuantity) + }, [product]) + + const changeQuantity = (variantId, quantity) => { + setVariantQuantity((variantQuantity) => ({ ...variantQuantity, [variantId]: quantity })) + } + + return ( + +
+
+
+ {product.name} +
+
+

{product?.name}

+
+
+
Nomor SKU
+
SKU-{product.id}
+
+
+
Part Number
+
{product.code || '-'}
+
+
+
Manufacture
+
+ {product.manufacture?.name ? ( + {product.manufacture?.name} + ) : ( +
-
+ )} +
+
+
+
Berat Barang
+
+ {product?.weight > 0 && {product?.weight} KG} + {product?.weight == 0 && ( + + Tanya Berat + + )} +
+
+
+
+
+ {product.variants.length > 1 && product.lowestPrice.priceDiscount > 0 && ( +
Harga mulai dari:
+ )} + {product?.lowestPrice.discountPercentage > 0 && ( +
+
+ {product?.lowestPrice.discountPercentage}% +
+
+ {currencyFormat(product?.lowestPrice.price)} +
+
+ )} +

+ {product?.lowestPrice.priceDiscount > 0 ? ( + currencyFormat(product?.lowestPrice.priceDiscount) + ) : ( + + Hubungi kami untuk dapatkan harga terbaik,  + + klik disini + + + )} +

+ + +
+ +
+
+
+ +
+
Varian Produk
+
+ + + + + + + + + + + {product.variants.map((variant) => ( + + + + + + + ))} + +
No. SKUHargaJumlahAction
{variant.code} + {variant.price.discountPercentage > 0 && ( + <> + + {currencyFormat(variant.price.price)} + {' '} + + )} + {currencyFormat(variant.price.priceDiscount)} + + changeQuantity(variant.id, e.target.value)} + /> + + + +
+
+
+
+
+ ) +} + +export default ProductDesktop -- cgit v1.2.3