From 094c341e35376ee2c20e12031830c3020ffb251d Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Sat, 14 Oct 2023 09:13:50 +0700
Subject: delete brand and category 0, & add product found in category filter

---
 src/lib/product/components/ProductSearch.jsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

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

diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index 3c954548..fd75d587 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -75,7 +75,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
   ) {
     const brand = productSearch.data?.facetCounts?.facetFields?.manufactureName[i]
     const qty = productSearch.data?.facetCounts?.facetFields?.manufactureName[i + 1]
-    brands.push({ brand, qty })
+    if (qty > 0) {
+      brands.push({ brand, qty })
+    }
   }
   /*const brandsList = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter(
     (value, index) => {
@@ -87,13 +89,22 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
     }
   )*/
 
-  const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter(
+  const categories = []
+  for (let i = 0; i < productSearch.data?.facetCounts?.facetFields?.categoryName.length; i += 2) {
+    const name = productSearch.data?.facetCounts?.facetFields?.categoryName[i]
+    const qty = productSearch.data?.facetCounts?.facetFields?.categoryName[i + 1]
+    if (qty > 0) {
+      categories.push({ name, qty })
+    }
+  }
+  
+  /*const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter(
     (value, index) => {
       if (index % 2 === 0) {
         return true
       }
     }
-  )
+  )*/
 
   const orderOptions = [
     { value: 'price-asc', label: 'Harga Terendah' },
-- 
cgit v1.2.3

