From bdfaa0b8564e89d72ffd2de93eb088e8cf0db31e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 2 Oct 2023 17:07:20 +0700 Subject: mapping new pricelist --- src/lib/product/components/ProductCard.jsx | 43 +++++++++++++++++++++--------- src/pages/api/shop/search.js | 14 +++++----- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 10ffdaec..83b26449 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -89,23 +89,40 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { > {product?.name} - {product?.lowestPrice.discountPercentage > 0 && ( -
-
- {currencyFormat(product.lowestPrice.price)} + {product?.flashSale?.id > 0 ? ( + <> + {product?.lowestPrice.discountPercentage > 0 && ( +
+
+ {currencyFormat(product.lowestPrice.price)} +
+
{product?.lowestPrice.discountPercentage}%
+
+ )} + +
+ {product?.lowestPrice.priceDiscount > 0 ? ( + currencyFormat(product?.lowestPrice.priceDiscount) + ) : ( + Call for price + )}
-
{product?.lowestPrice.discountPercentage}%
+ + ) : ( +
+ {product?.lowestPrice.price > 0 ? ( + <> + {currencyFormat(product?.lowestPrice.price)} +
+ Incl {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
diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 57b16db8..79083ee7 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -104,17 +104,19 @@ const escapeSolrQuery = (query) => { const productResponseMap = (products, pricelist) => { return products.map((product) => { - let price = product.price_f || 0 + let price = price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 let discountPercentage = product.discount_f || 0 if (pricelist) { - const pricelistDiscount = product?.[`price_${pricelist}_f`] || false - const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false + // const pricelistDiscount = product?.[`price_${pricelist}_f`] || false + // const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false - if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount - if (pricelistDiscountPerc && pricelistDiscountPerc > 0) - discountPercentage = pricelistDiscountPerc + // if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount + // if (pricelistDiscountPerc && pricelistDiscountPerc > 0) + // discountPercentage = pricelistDiscountPerc + + price = product?.[`price_${pricelist}_v2_f`] || 0 } if (product?.flashsale_id_i > 0) { -- cgit v1.2.3 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 ++++++++++----- src/pages/api/shop/search.js | 2 +- 6 files changed, 206 insertions(+), 133 deletions(-) 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
diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 79083ee7..7b44ef37 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -104,7 +104,7 @@ const escapeSolrQuery = (query) => { const productResponseMap = (products, pricelist) => { return products.map((product) => { - let price = price_tier1_v2_f || 0 + let price = product.price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 let discountPercentage = product.discount_f || 0 -- cgit v1.2.3 From dde4c79768532247abae4a1d188c82f2d601fbe0 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 3 Oct 2023 17:11:13 +0700 Subject: check if flashsale in cart --- src/lib/cart/components/Cart.jsx | 2 +- src/lib/cart/components/Cartheader.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index b5976a1b..acd23af6 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -685,7 +685,7 @@ const Cart = () => { - {product?.price?.discountPercentage > 0 && ( + {product?.hasFlashsale && (
{currencyFormat(product?.price?.price)} diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx index cbe7c7e1..901b1501 100644 --- a/src/lib/cart/components/Cartheader.jsx +++ b/src/lib/cart/components/Cartheader.jsx @@ -204,7 +204,7 @@ const Cardheader = (cartCount) => {

- {product?.price?.discountPercentage > 0 && ( + {product?.hasFlashsale && (
{product?.price?.discountPercentage}% -- cgit v1.2.3 From eb7bea2f262ffa4faa39d4f163950892c5640c0f Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 4 Oct 2023 10:09:43 +0700 Subject: pricelist di cart dan list variant --- .../product/components/Product/ProductDesktop.jsx | 64 ++++++++++++++-------- .../product/components/Product/ProductMobile.jsx | 2 - .../components/Product/ProductMobileVariant.jsx | 1 - src/lib/variant/components/VariantGroupCard.jsx | 1 - src/pages/api/shop/product-detail.js | 15 ++--- 5 files changed, 48 insertions(+), 35 deletions(-) diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 0df60673..30424943 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -452,7 +452,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
- Termasuk PPN: {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)} + Termasuk PPN:{' '} + {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
) : ( @@ -461,7 +462,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { <> {currencyFormat(lowestPrice?.price)}
- Termasuk PPN: {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)} + Termasuk PPN:{' '} + {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)}
) : ( @@ -575,32 +577,50 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { - {variant.price.discountPercentage > 0 && + {variant.isFlashsale ? ( + <> +
+
+ {lowestPrice?.discountPercentage}% +
+
+ {currencyFormat(variant.price.price)} +
{' '} +
+ {currencyFormat(variant.price.priceDiscount)} +
{' '} +
+ {currencyFormat(variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} + + ) : ( +
+ {variant.price.price > 0 ? ( + currencyFormat(variant.price.price * process.env.NEXT_PUBLIC_PPN) + ) : ( + + Call for price + + )} +
+ )} + {/* {variant.price.discountPercentage > 0 && variant.price.priceDiscount > 0 && ( <>
{currencyFormat(variant.price.price)}
{' '} - )} -
- {variant.price.priceDiscount > 0 ? ( - currencyFormat(variant.price.priceDiscount) - ) : ( - - Call for price - - )} -
+ )} */} + {/* */} diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index a9d34683..94312d31 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -152,8 +152,6 @@ 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}`, diff --git a/src/lib/product/components/Product/ProductMobileVariant.jsx b/src/lib/product/components/Product/ProductMobileVariant.jsx index a7b1a543..8cdb631f 100644 --- a/src/lib/product/components/Product/ProductMobileVariant.jsx +++ b/src/lib/product/components/Product/ProductMobileVariant.jsx @@ -82,7 +82,6 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { }) setAddCartAlert(true) } - console.log('ini log', activeVariant) const handleClickBuy = () => { if (!validAction()) return diff --git a/src/lib/variant/components/VariantGroupCard.jsx b/src/lib/variant/components/VariantGroupCard.jsx index dd5983a9..1e921546 100644 --- a/src/lib/variant/components/VariantGroupCard.jsx +++ b/src/lib/variant/components/VariantGroupCard.jsx @@ -4,7 +4,6 @@ import Image from '@/core/components/elements/Image/Image' import currencyFormat from '@/core/utils/currencyFormat' const VariantGroupCard = ({ variants, ...props }) => { - console.log('variant', variants) const [showAll, setShowAll] = useState(false) const variantsToShow = showAll ? variants : variants.slice(0, 2) diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index 5c3a8231..23adcb5f 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -26,17 +26,19 @@ export default async function handler(req, res) { const productResponseMap = (products, pricelist) => { return products.map((product) => { - let price = product.price_f || 0 + let price = product.price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 let discountPercentage = product.discount_f || 0 if (pricelist) { - const pricelistDiscount = product?.[`price_${pricelist}_f`] || false + /*const pricelistDiscount = product?.[`price_${pricelist}_f`] || false const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount if (pricelistDiscountPerc && pricelistDiscountPerc > 0) discountPercentage = pricelistDiscountPerc + */ + price = product?.[`price_${pricelist}_v2_f`] || 0 } if (product?.flashsale_id_i > 0) { @@ -86,17 +88,12 @@ const productResponseMap = (products, pricelist) => { } const productVariantsResponseMap = (parent, products, pricelist) => { return products.map((product) => { - let price = product.price_f || 0 + let price = product.price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 let discountPercentage = product.discount_f || 0 if (pricelist) { - const pricelistDiscount = product?.[`price_${pricelist}_f`] || false - const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false - - if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount - if (pricelistDiscountPerc && pricelistDiscountPerc > 0) - discountPercentage = pricelistDiscountPerc + price = product?.[`price_${pricelist}_v2_f`] || 0 } if (product?.flashsale_id_i > 0) { -- cgit v1.2.3 From 5624207e88c272a8edde9c334393bca5ac20d3fc Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 4 Oct 2023 11:35:03 +0700 Subject: ketingaalan --- .../product/components/Product/ProductDesktop.jsx | 50 +++++++++++++++------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 30424943..16ff31aa 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -44,8 +44,13 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { const { setRefreshCart, refreshCart } = useProductCartContext() const getLowestPrice = useCallback(() => { - const prices = product.variants.map((variant) => variant.price) + const prices = product.variants.map((variant) => ({ + price: variant.price, + isFlashsale: variant.isFlashsale + })) const lowest = prices.reduce((lowest, price) => { + console.log('ini reduce lowest', lowest) + console.log('ini reduce price', price) return price.priceDiscount < lowest.priceDiscount ? price : lowest }, prices[0]) return lowest @@ -438,32 +443,32 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
)} */} - {product?.flashSale?.remainingTime > 0 ? ( + {lowestPrice?.isFlashsale ? ( <>
- {lowestPrice?.discountPercentage}% + {lowestPrice?.price?.discountPercentage}%
- {currencyFormat(lowestPrice?.price)} + {currencyFormat(lowestPrice?.price?.price)}
- {currencyFormat(lowestPrice?.priceDiscount)} + {currencyFormat(lowestPrice?.price?.priceDiscount)}
Termasuk PPN:{' '} - {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)} + {currencyFormat(lowestPrice?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
) : (

- {lowestPrice?.price > 0 ? ( + {lowestPrice?.price.price > 0 ? ( <> - {currencyFormat(lowestPrice?.price)} + {currencyFormat(lowestPrice?.price.price)}
Termasuk PPN:{' '} - {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)} + {currencyFormat(lowestPrice?.price.price * process.env.NEXT_PUBLIC_PPN)}
) : ( @@ -581,21 +586,36 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { <>
- {lowestPrice?.discountPercentage}% + {variant?.price?.discountPercentage}%
- {currencyFormat(variant.price.price)} + {currencyFormat(variant?.price?.price)}
{' '}
- {currencyFormat(variant.price.priceDiscount)} + {currencyFormat(variant?.price?.priceDiscount)}
{' '}
- {currencyFormat(variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} +
+ + PPN:{' '} + {currencyFormat( + variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN + )} +
) : (
- {variant.price.price > 0 ? ( - currencyFormat(variant.price.price * process.env.NEXT_PUBLIC_PPN) + {variant?.price?.price > 0 ? ( + <> +
+ {currencyFormat(variant?.price?.price)} +
{' '} +
+ + PPN:{' '} + {currencyFormat( + variant?.price?.priceDiscount * process.env.NEXT_PUBLIC_PPN + )} +
+ ) : ( Date: Wed, 4 Oct 2023 12:05:14 +0700 Subject: mobile version --- src/lib/cart/components/Cart.jsx | 30 +++++++++++++++---------- src/lib/checkout/components/Checkout.jsx | 35 +++++++++++++++++++----------- src/lib/variant/components/VariantCard.jsx | 2 +- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index acd23af6..5716d01b 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -32,7 +32,7 @@ const Cart = () => { const [cart, setCart] = useState(null) - const {setRefreshCart} = useProductCartContext() + const { setRefreshCart } = useProductCartContext() useEffect(() => { if (!auth) return @@ -115,7 +115,7 @@ const Cart = () => { selected: true }).then(() => { getCart().then(() => { - if(promotionActiveId){ + if (promotionActiveId) { setPromotionType(false) } }) @@ -438,7 +438,7 @@ const Cart = () => { product.program.items && product.program.items.map((item) => (
- + { - {product?.hasFlashsale && ( -
-
- {currencyFormat(product?.price?.price)} + {product?.hasFlashsale ? ( + <> +
+
+ {currencyFormat(product?.price?.price)} +
+
+ {product?.price?.discountPercentage}% +
-
- {product?.price?.discountPercentage}% +
+ {currencyFormat(product?.price?.priceDiscount)}
+ + ) : ( +
+ {currencyFormat(product?.price?.price)}
)} -
- {currencyFormat(product?.price?.priceDiscount)} -
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 6d2f62e0..4739cd18 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -633,8 +633,11 @@ const Checkout = () => { Berakhir dalam{' '} {item.remainingTime} lagi,{' '}
-
handlingTnC(item)} > - Baca S&K +
handlingTnC(item)} + > + Baca S&K
@@ -1045,21 +1048,27 @@ const Checkout = () => { /> - {product?.price?.discountPercentage > 0 && ( -
-
- {currencyFormat(product?.price?.price)} + {product?.hasFlashsale ? ( + <> +
+
+ {currencyFormat(product?.price?.price)} +
+
+ {product?.price?.discountPercentage}% +
-
- {product?.price?.discountPercentage}% +
+ {currencyFormat(product?.price?.priceDiscount)}
+ + ) : ( +
+ {product.price.priceDiscount > 0 + ? currencyFormat(product?.price?.priceDiscount) + : 'Call For Price'}
)} -
- {product.price.priceDiscount > 0 - ? currencyFormat(product?.price?.priceDiscount) - : 'Call For Price'} -
diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx index 0f9f02f6..64b6d146 100644 --- a/src/lib/variant/components/VariantCard.jsx +++ b/src/lib/variant/components/VariantCard.jsx @@ -43,7 +43,7 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { Berat Item : {product?.weight} Kg

- {product.price.discountPercentage > 0 && ( + {product.hasFlashsale && ( <>

{currencyFormat(product.price.price)} -- cgit v1.2.3 From 1deaba0e528600f524df68463140bfef30aa155a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 4 Oct 2023 13:10:30 +0700 Subject: Fix product map on search solr --- src/pages/api/shop/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 7b44ef37..823e2a61 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -116,7 +116,7 @@ const productResponseMap = (products, pricelist) => { // if (pricelistDiscountPerc && pricelistDiscountPerc > 0) // discountPercentage = pricelistDiscountPerc - price = product?.[`price_${pricelist}_v2_f`] || 0 + price = product?.[`price_${pricelist}_f`] || 0 } if (product?.flashsale_id_i > 0) { -- cgit v1.2.3 From f14ff937c240edf636e0df66521ca30c3e6a8dcd Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 4 Oct 2023 13:39:31 +0700 Subject: bugs fix --- src/pages/api/shop/product-detail.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index 23adcb5f..60433459 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -38,7 +38,7 @@ const productResponseMap = (products, pricelist) => { if (pricelistDiscountPerc && pricelistDiscountPerc > 0) discountPercentage = pricelistDiscountPerc */ - price = product?.[`price_${pricelist}_v2_f`] || 0 + price = product?.[`price_${pricelist}_f`] || 0 } if (product?.flashsale_id_i > 0) { @@ -93,7 +93,7 @@ const productVariantsResponseMap = (parent, products, pricelist) => { let discountPercentage = product.discount_f || 0 if (pricelist) { - price = product?.[`price_${pricelist}_v2_f`] || 0 + price = product?.[`price_${pricelist}_f`] || 0 } if (product?.flashsale_id_i > 0) { -- cgit v1.2.3 From 72e7db4e20c2999bc4e6db3cef2ebe281898e915 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 4 Oct 2023 13:56:11 +0700 Subject: mapping product solr --- src/pages/api/shop/product-detail.js | 16 ++--- src/pages/api/shop/search.js | 7 ++- src/utils/solrMapping.js | 113 +++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 14 deletions(-) create mode 100644 src/utils/solrMapping.js diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index 60433459..e9236571 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -1,3 +1,4 @@ +import { productMappingSolr, variantsMappingSolr } from '@/utils/solrMapping' import axios from 'axios' export default async function handler(req, res) { @@ -11,8 +12,8 @@ export default async function handler(req, res) { ) let { auth } = req.cookies if (auth) auth = JSON.parse(auth) - let result = productResponseMap(productTemplate.data.response.docs, auth?.pricelist || false) - result[0].variants = productVariantsResponseMap( + let result = productMappingSolr(productTemplate.data.response.docs, auth?.pricelist || false) + result[0].variants = variantsMappingSolr( productTemplate.data.response.docs[0], productVariants.data.response.docs, auth?.pricelist || false @@ -24,20 +25,13 @@ export default async function handler(req, res) { } } -const productResponseMap = (products, pricelist) => { +/*const productResponseMap = (products, pricelist) => { return products.map((product) => { let price = product.price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 let discountPercentage = product.discount_f || 0 if (pricelist) { - /*const pricelistDiscount = product?.[`price_${pricelist}_f`] || false - const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false - - if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount - if (pricelistDiscountPerc && pricelistDiscountPerc > 0) - discountPercentage = pricelistDiscountPerc - */ price = product?.[`price_${pricelist}_f`] || 0 } @@ -141,4 +135,4 @@ const flashsaleTime = (endDate) => { const timeDifferenceInSeconds = timeDifferenceInMillis / 1000 return { remainingTime: timeDifferenceInSeconds, isFlashSale: flashsaleEndDate > currentTime } -} +}*/ diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 823e2a61..2120a442 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -1,3 +1,4 @@ +import { productMappingSolr } from '@/utils/solrMapping' import axios from 'axios' import camelcaseObjectDeep from 'camelcase-object-deep' @@ -73,7 +74,7 @@ export default async function handler(req, res) { try { let { auth } = req.cookies if (auth) auth = JSON.parse(auth) - result.data.response.products = productResponseMap( + result.data.response.products = productMappingSolr( result.data.response.docs, auth?.pricelist || false ) @@ -102,7 +103,7 @@ const escapeSolrQuery = (query) => { return escapedWords.join(' ') } -const productResponseMap = (products, pricelist) => { +/*const productResponseMap = (products, pricelist) => { return products.map((product) => { let price = product.price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 @@ -158,4 +159,4 @@ const productResponseMap = (products, pricelist) => { ] return productMapped }) -} +}*/ diff --git a/src/utils/solrMapping.js b/src/utils/solrMapping.js new file mode 100644 index 00000000..c8bd54ea --- /dev/null +++ b/src/utils/solrMapping.js @@ -0,0 +1,113 @@ +export const productMappingSolr = (products, pricelist) => { + return products.map((product) => { + let price = product.price_tier1_v2_f || 0 + let priceDiscount = product.price_discount_f || 0 + let discountPercentage = product.discount_f || 0 + + if (pricelist) { + price = product?.[`price_${pricelist}_f`] || 0 + } + + if (product?.flashsale_id_i > 0) { + price = product?.flashsale_base_price_f || 0 + priceDiscount = product?.flashsale_price_f || 0 + discountPercentage = product?.flashsale_discount_f || 0 + } + + let productMapped = { + id: product.product_id_i || '', + image: product.image_s || '', + code: product.default_code_s || '', + description: product.description_t || '', + displayName: product.display_name_s || '', + name: product.name_s || '', + lowestPrice: { price, priceDiscount, discountPercentage }, + variantTotal: product.variant_total_i || 0, + stockTotal: product.stock_total_f || 0, + weight: product.weight_f || 0, + manufacture: {}, + categories: [], + flashSale: { + id: product?.flashsale_id_i, + remainingTime: flashsaleTime(product?.flashsale_end_date_s)?.remainingTime, + name: product?.product?.flashsale_name_s, + tag: product?.flashsale_tag_s || 'FLASH SALE' + } + } + + if (product.manufacture_id_i && product.manufacture_name_s) { + productMapped.manufacture = { + id: product.manufacture_id_i || '', + name: product.manufacture_name_s || '', + imagePromotion1: product.image_promotion_1_s || '', + imagePromotion2: product.image_promotion_2_s || '' + } + } + + productMapped.categories = [ + { + id: product.category_id_i || '', + name: product.category_name_s || '' + } + ] + return productMapped + }) +} + +export const variantsMappingSolr = (parent, products, pricelist) => { + return products.map((product) => { + let price = product.price_tier1_v2_f || 0 + let priceDiscount = product.price_discount_f || 0 + let discountPercentage = product.discount_f || 0 + + if (pricelist) { + price = product?.[`price_${pricelist}_f`] || 0 + } + + if (product?.flashsale_id_i > 0) { + price = product?.flashsale_base_price_f || 0 + priceDiscount = product?.flashsale_price_f || 0 + discountPercentage = product?.flashsale_discount_f || 0 + } + + let productMapped = { + attributes: product.attributes || [], + id: product.product_id_i || '', + image: product.image_s || '', + code: product.default_code_s || '', + isFlashsale: flashsaleTime(product?.flashsale_end_date_s)?.isFlashSale, + isFlashsale: flashsaleTime(product?.flashsale_end_date_s)?.isFlashSale, + name: product.display_name_s || '', + price: { price, priceDiscount, discountPercentage }, + variantTotal: product.variant_total_i || 0, + stockTotal: product.stock_total_f || 0, + weight: product.weight_f || 0, + manufacture: {}, + parent: {} + } + + if (product.manufacture_id_i && product.manufacture_name_s) { + productMapped.manufacture = { + id: product.manufacture_id_i || '', + name: product.manufacture_name_s || '' + } + } + productMapped.parent = { + id: parent.product_id_i || '', + image: parent.image_s || '', + name: parent.name_s || '' + } + return productMapped + }) + } + +const flashsaleTime = (endDate) => { + const flashsaleEndDate = new Date(endDate) + const currentTime = new Date() + + const timeDifferenceInMillis = flashsaleEndDate - currentTime + const timeDifferenceInSeconds = timeDifferenceInMillis / 1000 + + return { remainingTime: timeDifferenceInSeconds, isFlashSale: flashsaleEndDate > currentTime } + } + -- cgit v1.2.3 From 427feacedcdc511fcead8d2289264aa58bafd038 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 4 Oct 2023 15:34:39 +0700 Subject: set tier auth --- src/lib/product/components/Product/ProductDesktop.jsx | 2 -- src/pages/api/shop/product-detail.js | 7 +++---- src/pages/shop/product/[slug].jsx | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 16ff31aa..5e827089 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -49,8 +49,6 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { isFlashsale: variant.isFlashsale })) const lowest = prices.reduce((lowest, price) => { - console.log('ini reduce lowest', lowest) - console.log('ini reduce price', price) return price.priceDiscount < lowest.priceDiscount ? price : lowest }, prices[0]) return lowest diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index e9236571..e77ae53a 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -10,13 +10,12 @@ export default async function handler(req, res) { process.env.SOLR_HOST + `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100` ) - let { auth } = req.cookies - if (auth) auth = JSON.parse(auth) - let result = productMappingSolr(productTemplate.data.response.docs, auth?.pricelist || false) + let auth = req.query.auth + let result = productMappingSolr(productTemplate.data.response.docs, auth || false) result[0].variants = variantsMappingSolr( productTemplate.data.response.docs[0], productVariants.data.response.docs, - auth?.pricelist || false + auth || false ) res.status(200).json(result) } catch (error) { diff --git a/src/pages/shop/product/[slug].jsx b/src/pages/shop/product/[slug].jsx index 534aa8da..7351da2f 100644 --- a/src/pages/shop/product/[slug].jsx +++ b/src/pages/shop/product/[slug].jsx @@ -18,10 +18,11 @@ export async function getServerSideProps(context) { const cookies = context.req.headers.cookie const cookieObj = cookies ? cookie.parse(cookies) : {} const auth = cookieObj.auth ? JSON.parse(cookieObj.auth) : {} + const tier = auth.pricelist const authToken = auth?.token || '' let response = await axios( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/product-detail?id=` + getIdFromSlug(slug) + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/product-detail?id=` + getIdFromSlug(slug) +'&auth=' + tier ) let product = response.data // let productSolr = await productApi({ id: getIdFromSlug(slug), headers: { Token: authToken } }) -- cgit v1.2.3 From e72c16eb549488e1ed847b022880f542d2a9c525 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 5 Oct 2023 09:32:12 +0700 Subject: add component list product for cart, quotation, and checkout --- .../elements/Product/cartProductsList.jsx | 260 +++++++++++++++++++++ src/lib/cart/components/Cart.jsx | 257 +------------------- src/lib/checkout/components/Checkout.jsx | 8 +- .../product/components/Product/ProductDesktop.jsx | 4 +- src/lib/product/components/ProductCard.jsx | 6 +- src/lib/quotation/components/Quotation.jsx | 66 +----- 6 files changed, 276 insertions(+), 325 deletions(-) create mode 100644 src/core/components/elements/Product/cartProductsList.jsx diff --git a/src/core/components/elements/Product/cartProductsList.jsx b/src/core/components/elements/Product/cartProductsList.jsx new file mode 100644 index 00000000..c1d96d96 --- /dev/null +++ b/src/core/components/elements/Product/cartProductsList.jsx @@ -0,0 +1,260 @@ +import Link from '@/core/components/elements/Link/Link' +import Image from '@/core/components/elements/Image/Image' +import LogoSpinner from '../Spinner/LogoSpinner' +import { TrashIcon } from '@heroicons/react/24/outline' +import { useEffect } from 'react' +import { createSlug } from '@/core/utils/slug' +import currencyFormat from '@/core/utils/currencyFormat' + +const CardProdcuctsList = ({ + isLoading, + products, + source, + handlePopUpPromo = () => {}, + toggleSelected = () => {}, + updateQuantity = () => {}, + setDeleteConfirmation = () => {} +}) => { + return ( + + + + + + + + {source == 'cart' && } + + + + {isLoading && ( + + + + )} + {!isLoading && (!products || products?.length == 0) && ( + + + + )} + {products && + products?.map((product) => ( + <> + {product.hasProgram && ( + + + + )} + + + + + + + {source == 'cart' && ( + + )} + + {product?.program?.items && ( + + {product.program.items.map((item) => ( + <> + + + + + + + + ))} + + )} + + ))} + +
Nama ProdukJumlahHargaSubtotalAction
+
+ +
+
Keranjang belanja anda masih kosong
+
+ {product.program ? ( + <> +
+ {product.program.type.label} +
+
+ {product.program.type.value == 'merchandise' ? ( + <>Selamat anda mendapatkan merchandise indoteknik.com + ) : ( + <> + Selamat! Pembelian anda lebih hemat + + {' '} + {currencyFormat(product.program?.totalSavings)} + + + )} +
+ + ) : ( + <> +
+ Promo +
+
Pilih Promo Yang Tersedia Bisa lebih Hemat
+ + )} +
+ handlePopUpPromo(product.id, product.quantity, product.program?.id) + } + className='ml-auto text-red-500 flex gap-x-1 cursor-pointer' + > +
Cek Promo
+
+ +
+
+
+
+ + toggleSelected(product.id)} + checked={product?.selected} + className='accent-danger-500 w-4' + /> + + + + {product?.name} + +
+ + {product?.parent?.name} + +
+ {product?.code}{' '} + {product?.attributes.length > 0 ? `| ${product?.attributes.join(', ')}` : ''} +
+
+
+ + updateQuantity(e.target.value, product?.id)} + onBlur={(e) => updateQuantity(e.target.value, product?.id, 'BLUR')} + /> + + + {product?.hasFlashsale ? ( + <> +
+
+ {currencyFormat(product?.price?.price)} +
+
{product?.price?.discountPercentage}%
+
+
+ {currencyFormat(product?.price?.priceDiscount)} +
+ + ) : ( +
{currencyFormat(product?.price?.price)}
+ )} +
+ +
+ {currencyFormat(product?.price?.priceDiscount * product?.quantity)} +
+
+
+ +
+
+ + + +
+ {item.name} +
+
+
+ + {product.program.type.label} + +
+
{item.name}
+
+
+ + + + + {item?.price?.discountPercentage > 0 && ( +
+
+ {currencyFormat(product?.price?.price)} +
+
+ )} +
+ {item?.price.priceDiscount > 0 ? 'Gratis' : ''} +
+
+ +
+ {item.price.priceDiscount > 0 ? 'Gratis' : ''} +
+
+ ) +} + +const ComponentCanBuy = ({ canBuy }) => + !canBuy &&

+ +export default CardProdcuctsList diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index 5716d01b..c6aaa596 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -23,6 +23,8 @@ import { getPromotionProgram } from '@/lib/promotinProgram/api/homepageApi' import PromotionType from '@/lib/promotinProgram/components/PromotionType' import { gtagBeginCheckout } from '@/core/utils/googleTag' import { useProductCartContext } from '@/contexts/ProductCartContext' +import CardProdcuctsList from '@/core/components/elements/Product/cartProductsList' +// import cardProdcuctsList from '@/core/components/elements/Product/cartProductsList' const Cart = () => { const router = useRouter() @@ -530,260 +532,7 @@ const Cart = () => {

Keranjang

- - - - - - - - - - - - {isLoading && ( - - - - )} - {!isLoading && (!products || products?.length == 0) && ( - - - - )} - {products && - products?.map((product) => ( - <> - {product.hasProgram && ( - - - - )} - - - - - - - - - {product?.program?.items && ( - - {product.program.items.map((item) => ( - <> - - - - - - - - ))} - - )} - - ))} - -
Nama ProdukJumlahHargaSubtotalAction
-
- -
-
Keranjang belanja anda masih kosong
-
- {product.program ? ( - <> -
- - {product.program.type.label} - -
-
- {product.program.type.value == 'merchandise' ? ( - <>Selamat anda mendapatkan merchandise indoteknik.com - ) : ( - <> - Selamat! Pembelian anda lebih hemat - - {' '} - {currencyFormat(product.program?.totalSavings)} - - - )} -
- - ) : ( - <> -
- Promo -
-
- Pilih Promo Yang Tersedia Bisa lebih Hemat -
- - )} -
- handlePopUpPromo( - product.id, - product.quantity, - product.program?.id - ) - } - className='ml-auto text-red-500 flex gap-x-1 cursor-pointer' - > -
Cek Promo
-
- -
-
-
-
- - toggleSelected(product.id)} - checked={product?.selected} - className='accent-danger-500 w-4' - /> - - - - {product?.name} - -
- - {product?.parent?.name} - -
- {product?.code}{' '} - {product?.attributes.length > 0 - ? `| ${product?.attributes.join(', ')}` - : ''} -
-
-
- - updateQuantity(e.target.value, product?.id)} - onBlur={(e) => updateQuantity(e.target.value, product?.id, 'BLUR')} - /> - - - {product?.hasFlashsale ? ( - <> -
-
- {currencyFormat(product?.price?.price)} -
-
- {product?.price?.discountPercentage}% -
-
-
- {currencyFormat(product?.price?.priceDiscount)} -
- - ) : ( -
- {currencyFormat(product?.price?.price)} -
- )} -
- -
- {currencyFormat(product?.price?.priceDiscount * product?.quantity)} -
-
-
- -
-
- - - -
- {item.name} -
-
-
- - {product.program.type.label} - -
-
{item.name}
-
-
- - - - - {item?.price?.discountPercentage > 0 && ( -
-
- {currencyFormat(product?.price?.price)} -
-
- )} -
- {item?.price.priceDiscount > 0 ? 'Gratis' : ''} -
-
- -
- {item.price.priceDiscount > 0 ? 'Gratis' : ''} -
-
+
{
Detail Pesanan
- + + + + {/*
@@ -1148,7 +1152,7 @@ const Checkout = () => { )) )} -
Nama Produk
+ */}
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 5e827089..4c8c3ae9 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -594,7 +594,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
{' '}
- + PPN:{' '} + Inc. PPN:{' '} {currencyFormat( variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN )} @@ -608,7 +608,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { {currencyFormat(variant?.price?.price)}
{' '}
- + PPN:{' '} + Inc. PPN:{' '} {currencyFormat( variant?.price?.priceDiscount * process.env.NEXT_PUBLIC_PPN )} diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 16c63c00..6a5e29ab 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -113,8 +113,8 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {product?.lowestPrice.price > 0 ? ( <> {currencyFormat(product?.lowestPrice.price)} -
- + PPN: {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN)} +
+ Inc. PPN: {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN )}
) : ( @@ -217,7 +217,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { <> {currencyFormat(product?.lowestPrice.price)}
- + PPN: {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN)} + Inc. PPN: {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN)}
) : ( diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index cee35457..8c379ead 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -16,6 +16,7 @@ import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' import Image from '@/core/components/elements/Image/Image' import { useQuery } from 'react-query' +import CardProdcuctsList from '@/core/components/elements/Product/cartProductsList' const { checkoutApi } = require('@/lib/checkout/api/checkoutApi') const { getProductsCheckout } = require('@/lib/checkout/api/checkoutApi') @@ -174,70 +175,7 @@ const Quotation = () => {
Detail Barang
- - - - - - - - - - - {products?.map((product) => ( - - - - - - - ))} - -
Nama ProdukJumlahHargaSubtotal
-
- {product?.name} -
-
-
- {product?.parent?.name} -
-
- {product?.code}{' '} - {product?.attributes.length > 0 - ? `| ${product?.attributes.join(', ')}` - : ''} -
-
-
- - - {product?.price?.discountPercentage > 0 && ( -
-
- {currencyFormat(product?.price?.price)} -
-
- {product?.price?.discountPercentage}% -
-
- )} -
- {currencyFormat(product?.price?.priceDiscount)} -
-
-
- {currencyFormat(product?.price?.priceDiscount * product?.quantity)} -
-
+
-- cgit v1.2.3 From 760a7199aafb1d7f995611f9b6bca1379dfc4b65 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 5 Oct 2023 09:54:22 +0700 Subject: hide checkbox if source != cart --- .../components/elements/Product/cartProductsList.jsx | 20 +++++++++++++------- src/lib/checkout/components/Checkout.jsx | 1 - 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/components/elements/Product/cartProductsList.jsx b/src/core/components/elements/Product/cartProductsList.jsx index c1d96d96..7a95f1f1 100644 --- a/src/core/components/elements/Product/cartProductsList.jsx +++ b/src/core/components/elements/Product/cartProductsList.jsx @@ -108,13 +108,17 @@ const CardProdcuctsList = ({ className={`${product.hasProgram ? '!border-t-0 !border-b-0' : ''}`} > - - toggleSelected(product.id)} - checked={product?.selected} - className='accent-danger-500 w-4' - /> + {source == 'cart' && ( + <> + + toggleSelected(product.id)} + checked={product?.selected} + className='accent-danger-500 w-4' + /> + + )} @@ -139,6 +143,7 @@ const CardProdcuctsList = ({ {product?.code}{' '} {product?.attributes.length > 0 ? `| ${product?.attributes.join(', ')}` : ''}
+
Berat item : {product?.weight} Kg
@@ -189,6 +194,7 @@ const CardProdcuctsList = ({ )} + {/* Component for promotion program product */} {product?.program?.items && ( {product.program.items.map((item) => ( diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 6b7852f2..e2c1a85b 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -989,7 +989,6 @@ const Checkout = () => {
Detail Pesanan
- {/* -- cgit v1.2.3 From e9f65fadbfcf319db1f2f73e0984acad4f9aa505 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 5 Oct 2023 10:35:30 +0700 Subject: error query params --- src/core/components/elements/Product/cartProductsList.jsx | 1 + src/pages/api/shop/product-detail.js | 2 +- src/pages/shop/product/[slug].jsx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/components/elements/Product/cartProductsList.jsx b/src/core/components/elements/Product/cartProductsList.jsx index 7a95f1f1..5887b425 100644 --- a/src/core/components/elements/Product/cartProductsList.jsx +++ b/src/core/components/elements/Product/cartProductsList.jsx @@ -15,6 +15,7 @@ const CardProdcuctsList = ({ updateQuantity = () => {}, setDeleteConfirmation = () => {} }) => { + return (
diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index e77ae53a..8571b623 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -10,7 +10,7 @@ export default async function handler(req, res) { process.env.SOLR_HOST + `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100` ) - let auth = req.query.auth + let auth = JSON.parse(req.query.auth) let result = productMappingSolr(productTemplate.data.response.docs, auth || false) result[0].variants = variantsMappingSolr( productTemplate.data.response.docs[0], diff --git a/src/pages/shop/product/[slug].jsx b/src/pages/shop/product/[slug].jsx index 7351da2f..63fb2e7e 100644 --- a/src/pages/shop/product/[slug].jsx +++ b/src/pages/shop/product/[slug].jsx @@ -18,7 +18,7 @@ export async function getServerSideProps(context) { const cookies = context.req.headers.cookie const cookieObj = cookies ? cookie.parse(cookies) : {} const auth = cookieObj.auth ? JSON.parse(cookieObj.auth) : {} - const tier = auth.pricelist + const tier = auth.pricelist ? auth.pricelist : false const authToken = auth?.token || '' let response = await axios( -- cgit v1.2.3 From 3b7a99415cf1209c300c459bbae065d9cce17864 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 5 Oct 2023 10:44:48 +0700 Subject: bug fix json parse --- src/pages/api/shop/product-detail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index 8571b623..22a53df2 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -10,7 +10,7 @@ export default async function handler(req, res) { process.env.SOLR_HOST + `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100` ) - let auth = JSON.parse(req.query.auth) + let auth = req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth let result = productMappingSolr(productTemplate.data.response.docs, auth || false) result[0].variants = variantsMappingSolr( productTemplate.data.response.docs[0], -- cgit v1.2.3 From 5d4cf836d098e9c351bce4d25f0e88e341646ccc Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 6 Oct 2023 13:49:16 +0700 Subject: feedback pricelist product mobile --- src/lib/product/components/Product/ProductMobile.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index 94312d31..20a1d3f4 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -250,12 +250,12 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { ) : (

- {activeVariant?.price?.priceDiscount > 0 ? ( + {activeVariant?.price?.price > 0 ? ( <> - {currencyFormat(activeVariant?.price?.priceDiscount)} + {currencyFormat(activeVariant?.price?.price)}
Termasuk PPN:{' '} - {currencyFormat(activeVariant?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} + {currencyFormat(activeVariant?.price.price * process.env.NEXT_PUBLIC_PPN)}
) : ( -- cgit v1.2.3