From 094c341e35376ee2c20e12031830c3020ffb251d Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" 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/ProductFilter.jsx | 44 +++++++++++----------- .../product/components/ProductFilterDesktop.jsx | 9 +++-- src/lib/product/components/ProductSearch.jsx | 17 +++++++-- 3 files changed, 41 insertions(+), 29 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index 40bfc824..38e2d2c3 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -87,27 +87,25 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr return (
- {!router.pathname.includes('brands') && - !defaultBrand && ( -
- - -
- ) - } - + {!router.pathname.includes('brands') && !defaultBrand && ( +
+ + +
+ )} +
diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index cdfd85e8..582dabea 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -156,12 +156,15 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu {categories.map((category, index) => (
- {category} +
+ {category.name} + ({category.qty}) +
))} 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