summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-09-25 07:36:33 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-09-25 07:36:33 +0000
commit21a7d1e4aaa0ac58fd6d5dbb2942fcf91238e9c4 (patch)
tree66b2038f3e27da9ca183d1c0225670373977335d /src
parente8f640d3fd4984fe5854c2faf7ead9b3b5aebbf2 (diff)
parentea200698d878a54171857421cf20845998b3a228 (diff)
Merged in bug-product (pull request #334)
Bug product Approved-by: trisusilo
Diffstat (limited to 'src')
-rw-r--r--src/lib/product/components/ProductCard.jsx59
-rw-r--r--src/utils/solrMapping.js27
2 files changed, 46 insertions, 40 deletions
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx
index 22ce0533..d3b50302 100644
--- a/src/lib/product/components/ProductCard.jsx
+++ b/src/lib/product/components/ProductCard.jsx
@@ -17,12 +17,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
const [discount, setDiscount] = useState(0);
let voucherPastiHemat = 0;
-
- if (product?.voucherPastiHemat ? product?.voucherPastiHemat.length : voucherPastiHemat > 0) {
- const stringVoucher = product?.voucherPastiHemat[0];
- const validJsonString = stringVoucher.replace(/'/g, '"');
- voucherPastiHemat = JSON.parse(validJsonString);
- }
+ voucherPastiHemat = product?.newVoucherPastiHemat[0];
const callForPriceWhatsapp = whatsappUrl('product', {
name: product.name,
@@ -48,18 +43,18 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
const hitungDiscountVoucher = () => {
let countDiscount = 0;
- if (voucherPastiHemat.discount_type === 'percentage') {
+ if (voucherPastiHemat.discountType === 'percentage') {
countDiscount =
product?.lowestPrice.priceDiscount *
- (voucherPastiHemat.discount_amount / 100);
+ (voucherPastiHemat.discountAmount / 100);
if (
- voucherPastiHemat.max_discount > 0 &&
- countDiscount > voucherPastiHemat.max_discount
+ voucherPastiHemat.maxDiscount > 0 &&
+ countDiscount > voucherPastiHemat.maxDiscount
) {
- countDiscount = voucherPastiHemat.max_discount;
+ countDiscount = voucherPastiHemat.maxDiscount;
}
} else {
- countDiscount = voucherPastiHemat.discount_amount;
+ countDiscount = voucherPastiHemat.discountAmount;
}
setDiscount(countDiscount);
@@ -147,20 +142,24 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
</Link>
<div className='p-2 sm:p-3 pb-3 text-caption-2 sm:text-body-2 leading-5'>
<div className='flex justify-between '>
- {product?.manufacture?.name ? (
- <Link href={URL.manufacture} className='mb-1 mt-1'>
- {product.manufacture.name}
- </Link>
- ) : (
- <div>-</div>
- )}
- {product?.isInBu && (
- <Link href='/panduan-pick-up-service' className='group'>
- <Image src='/images/PICKUP-NOW.png' className='group-hover:scale-105 transition-transform duration-200' alt='pickup now' width={90} height={12} />
- </Link>
-
-
- )}
+ {product?.manufacture?.name ? (
+ <Link href={URL.manufacture} className='mb-1 mt-1'>
+ {product.manufacture.name}
+ </Link>
+ ) : (
+ <div>-</div>
+ )}
+ {product?.isInBu && (
+ <Link href='/panduan-pick-up-service' className='group'>
+ <Image
+ src='/images/PICKUP-NOW.png'
+ className='group-hover:scale-105 transition-transform duration-200'
+ alt='pickup now'
+ width={90}
+ height={12}
+ />
+ </Link>
+ )}
</div>
<Link
href={URL.product}
@@ -301,11 +300,11 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
</div>
)}
{product?.manufacture?.name ? (
- <div className='flex justify-between'>
+ <div className='flex justify-between'>
<Link href={URL.manufacture} className='mb-1'>
- {product.manufacture.name}
- </Link>
- {/* {product?.is_in_bu && (
+ {product.manufacture.name}
+ </Link>
+ {/* {product?.is_in_bu && (
<div className='bg-red-500 rounded'>
<span className='p-[6px] text-xs text-white'>
Click & Pickup
diff --git a/src/utils/solrMapping.js b/src/utils/solrMapping.js
index 0d50b99b..f73e966a 100644
--- a/src/utils/solrMapping.js
+++ b/src/utils/solrMapping.js
@@ -1,5 +1,5 @@
export const promoMappingSolr = (promotions) => {
- return promotions.map((promotion) =>{
+ return promotions.map((promotion) => {
let productMapped = {
id: promotion.id,
program_id: promotion.program_id_i,
@@ -16,14 +16,13 @@ export const promoMappingSolr = (promotions) => {
total_qty: promotion.total_qty_i,
products: JSON.parse(promotion.products_s) || '',
product_id: promotion.product_ids[0],
- qty_sold_f:promotion.total_qty_sold_f,
- free_products: JSON.parse(promotion.free_products_s)
+ qty_sold_f: promotion.total_qty_sold_f,
+ free_products: JSON.parse(promotion.free_products_s),
};
return productMapped;
- })
+ });
};
-
export const productMappingSolr = (products, pricelist) => {
return products.map((product) => {
let price = product.price_tier1_v2_f || 0;
@@ -62,10 +61,11 @@ export const productMappingSolr = (products, pricelist) => {
tag: product?.flashsale_tag_s || 'FLASH SALE',
},
qtySold: product?.qty_sold_f || 0,
- isTkdn:product?.tkdn_b || false,
- isSni:product?.sni_b || false,
- is_in_bu:product?.is_in_bu_b || false,
- voucherPastiHemat:product?.voucher_pastihemat || []
+ isTkdn: product?.tkdn_b || false,
+ isSni: product?.sni_b || false,
+ newVoucherPastiHemat: [],
+ is_in_bu: product?.is_in_bu_b || false,
+ voucherPastiHemat: product?.voucher_pastihemat || [],
};
if (product.manufacture_id_i && product.manufacture_name_s) {
@@ -83,6 +83,14 @@ export const productMappingSolr = (products, pricelist) => {
name: product.category_name_s || '',
},
];
+ productMapped.newVoucherPastiHemat = [
+ {
+ min_purchase: product.voucher_min_purchase_f || 0,
+ discount_type: product.voucher_discount_type_s || '',
+ discount_amount: product.voucher_discount_amount_f || 0,
+ max_discount: product.voucher_max_discount_f || 0,
+ },
+ ];
return productMapped;
});
};
@@ -149,4 +157,3 @@ const flashsaleTime = (endDate) => {
isFlashSale: flashsaleEndDate > currentTime,
};
};
-