From 6bd88bdb765c1ecc0518abeca77eca25bde2857b Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 17 Oct 2023 14:57:48 +0700
Subject: add lebel product terjual di product card dan product detail, bugfix
 queri solr untuk filter brand

---
 src/lib/product/components/Product/ProductMobile.jsx | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'src/lib/product/components/Product/ProductMobile.jsx')

diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx
index 70ac1cbc..ef2c0002 100644
--- a/src/lib/product/components/Product/ProductMobile.jsx
+++ b/src/lib/product/components/Product/ProductMobile.jsx
@@ -21,6 +21,7 @@ import ImageNext from 'next/image'
 import CountDown2 from '@/core/components/elements/CountDown/CountDown2'
 import Breadcrumb from './Breadcrumb'
 import useAuth from '@/core/hooks/useAuth'
+import { sellingProductFormat } from '@/core/utils/formatValue'
 
 const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
   const router = useRouter()
@@ -62,7 +63,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
     price: getLowestPrice(),
     stock: product.stockTotal,
     weight: product.weight,
-    hasProgram: false
+    hasProgram: false,
+    qtySold: product.qtySold
   })
 
   const variantOptions = product.variants?.map((variant) => {
@@ -105,7 +107,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
         stock: variant.stock,
         weight: variant.weight,
         hasProgram: variant.hasProgram,
-        isFlashsale: variant.isFlashsale
+        isFlashsale: variant.isFlashsale,
+        qtySold: variant.qtySold
       }
 
       setActiveVariant(newActiveVariant)
@@ -245,7 +248,9 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
           </button>
         </div>
         <h1 className='leading-6 font-medium mb-3'>{activeVariant?.name}</h1>
-
+        {product?.qtySold > 0 && (
+          <div className='text-gray_r-9'>{sellingProductFormat(activeVariant?.qtySold) + ' Terjual'}</div>
+        )}
         {product.variants.length > 1 &&
           activeVariant.price.priceDiscount > 0 &&
           !selectedVariant && (
-- 
cgit v1.2.3

