From 787d3aaa3187d3432c8e6b743b555ea3e4a4980c Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 3 Oct 2023 15:25:14 +0700 Subject: new pricelist di page product cart, product detail & product variant --- .../product/components/Product/ProductDesktop.jsx | 74 +++++++++++++++------- .../components/Product/ProductDesktopVariant.jsx | 71 ++++++++++++--------- .../product/components/Product/ProductMobile.jsx | 69 ++++++++++++-------- .../components/Product/ProductMobileVariant.jsx | 73 +++++++++++---------- src/lib/product/components/ProductCard.jsx | 50 ++++++++++----- 5 files changed, 205 insertions(+), 132 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 5cc35df7..0df60673 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -413,13 +413,13 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
Harga mulai dari:
)} - {lowestPrice?.discountPercentage > 0 && ( + {/* {lowestPrice?.discountPercentage > 0 && (
{lowestPrice?.discountPercentage}%
-
- {currencyFormat(lowestPrice?.price)} +
+ Include PPN {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)}
{product.flashSale.remainingTime > 0 && (
@@ -436,28 +436,54 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
)}
+ )} */} + + {product?.flashSale?.remainingTime > 0 ? ( + <> +
+
+ {lowestPrice?.discountPercentage}% +
+
+ {currencyFormat(lowestPrice?.price)} +
+
+ {currencyFormat(lowestPrice?.priceDiscount)} +
+
+
+ Termasuk PPN: {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)} +
+ + ) : ( +

+ {lowestPrice?.price > 0 ? ( + <> + {currencyFormat(lowestPrice?.price)} +
+ Termasuk PPN: {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)} +
+ + ) : ( + + Hubungi kami untuk dapatkan harga terbaik,  + + klik disini + + + )} +

)} -

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

+ {product.variants.length > 1 ? (
*/}
- {lowestPrice?.priceDiscount > 0 ? ( + {product?.flashSale?.remainingTime > 0 ? ( <> -
-
- Harga Sebelum PPN : -
-
- - {currencyFormat(lowestPrice?.priceDiscount)} - -
-
- Termasuk PPN : -
+
{lowestPrice?.discountPercentage}%
-
- {currencyFormat(lowestPrice?.price * 1.11)} +
+ {currencyFormat(lowestPrice?.price)}
-

- {currencyFormat(lowestPrice?.priceDiscount * 1.11)} -

+
+ {currencyFormat(lowestPrice?.priceDiscount)} +
+
+
+ Termasuk PPN:{' '} + {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
) : ( - - Hubungi kami untuk dapatkan harga terbaik,  - - klik disini - - +

+ {lowestPrice?.price > 0 ? ( + <> + {currencyFormat(lowestPrice?.price)} +
+ Termasuk PPN:{' '} + {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)} +
+ + ) : ( + + Hubungi kami untuk dapatkan harga terbaik,  + + klik disini + + + )} +

)}
{ price: variant.price, stock: variant.stock, weight: variant.weight, - hasProgram: variant.hasProgram + hasProgram: variant.hasProgram, + isFlashsale: variant.isFlashsale } setActiveVariant(newActiveVariant) @@ -151,6 +152,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { router.push(`/shop/checkout?source=buy`) } + console.log('ini log', activeVariant) + const productSimilarQuery = [ product?.name, `fq=-product_id_i:${product.id}`, @@ -231,32 +234,48 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
Harga mulai dari:
)} - {activeVariant?.price?.discountPercentage > 0 && ( -
-
- {currencyFormat(activeVariant?.price?.price)} + {activeVariant.isFlashsale ? ( + <> +
+
{activeVariant?.price?.discountPercentage}%
+
+ {currencyFormat(activeVariant?.price?.price)} +
+
+ {currencyFormat(activeVariant?.price?.priceDiscount)} +
-
{activeVariant?.price?.discountPercentage}%
-
+
+ Termasuk PPN:{' '} + {currencyFormat(activeVariant?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} +
+ + ) : ( +

+ {activeVariant?.price?.priceDiscount > 0 ? ( + <> + {currencyFormat(activeVariant?.price?.priceDiscount)} +
+ Termasuk PPN:{' '} + {currencyFormat(activeVariant?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} +
+ + ) : ( + + Hubungi kami untuk dapatkan harga terbaik,  + + klik disini + + + )} +

)} -

- {activeVariant?.price?.priceDiscount > 0 ? ( - currencyFormat(activeVariant?.price?.priceDiscount) - ) : ( - - Hubungi kami untuk dapatkan harga terbaik,  - - klik disini - - - )} -

diff --git a/src/lib/product/components/Product/ProductMobileVariant.jsx b/src/lib/product/components/Product/ProductMobileVariant.jsx index d0c209cc..a7b1a543 100644 --- a/src/lib/product/components/Product/ProductMobileVariant.jsx +++ b/src/lib/product/components/Product/ProductMobileVariant.jsx @@ -39,7 +39,8 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { name: product.name, price: getLowestPrice(), stock: product.stockTotal, - weight: product.weight + weight: product.weight, + isFlashSale: product.isFlashsale }) useEffect(() => { @@ -50,7 +51,8 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { name: product.name, price: product.price, stock: product.stock, - weight: product.weight + weight: product.weight, + isFlashSale: product.isFlashsale }) } }, [selectedVariant, product]) @@ -80,6 +82,7 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { }) setAddCartAlert(true) } + console.log('ini log', activeVariant) const handleClickBuy = () => { if (!validAction()) return @@ -139,47 +142,47 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => {

{activeVariant?.name}

- {activeVariant?.price?.priceDiscount > 0 ? ( + {activeVariant.isFlashsale ? ( <>
-
Harga Sebelum PPN :
-
- {' '} +
{activeVariant?.price?.discountPercentage}%
+
+ {currencyFormat(activeVariant?.price?.price)} +
+
{currencyFormat(activeVariant?.price?.priceDiscount)}
-
- Termasuk PPN : -
- {activeVariant?.price?.discountPercentage > 0 && ( - <> -
- {activeVariant?.price?.discountPercentage}% -
-
- {currencyFormat(activeVariant?.price?.price * 1.11)} -
- - )} -

- {currencyFormat(activeVariant?.price?.priceDiscount * 1.11)} -

-
+
+ Termasuk PPN:{' '} + {currencyFormat(activeVariant?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
) : ( - - Hubungi kami untuk dapatkan harga terbaik,  - - klik disini - - +

+ {activeVariant?.price?.priceDiscount > 0 ? ( + <> + {currencyFormat(activeVariant?.price?.priceDiscount)} +
+ Termasuk PPN:{' '} + {currencyFormat(activeVariant?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} +
+ + ) : ( + + Hubungi kami untuk dapatkan harga terbaik,  + + klik disini + + + )} +

)}
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 83b26449..16c63c00 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -82,7 +82,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )} { {product?.lowestPrice.price > 0 ? ( <> {currencyFormat(product?.lowestPrice.price)} -
- Incl {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN )} +
+ + PPN: {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN)}
) : ( @@ -186,30 +186,46 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )} {product?.name} + {product?.flashSale?.id > 0 ? ( + <> + {product?.lowestPrice.discountPercentage > 0 && ( +
+
{product?.lowestPrice?.discountPercentage}%
+
+ {currencyFormat(product?.lowestPrice?.price)} +
+
+ )} - {product?.lowestPrice?.discountPercentage > 0 && ( -
-
{product?.lowestPrice?.discountPercentage}%
-
- {currencyFormat(product?.lowestPrice?.price)} +
+ {product?.lowestPrice?.priceDiscount > 0 ? ( + currencyFormat(product?.lowestPrice?.priceDiscount) + ) : ( + Call for price + )}
+ + ) : ( +
+ {product?.lowestPrice.price > 0 ? ( + <> + {currencyFormat(product?.lowestPrice.price)} +
+ + PPN: {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN)} +
+ + ) : ( + Call for price + )}
)} -
- {product?.lowestPrice?.priceDiscount > 0 ? ( - currencyFormat(product?.lowestPrice?.priceDiscount) - ) : ( - Call for price - )} -
- {product?.stockTotal > 0 && (
Ready Stock
-- cgit v1.2.3