From 43e59b8c7f8b742e5781a8a8b991afcf9aabb90e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Sat, 14 Oct 2023 11:08:42 +0700 Subject: add information label if brand and categories in empty --- src/lib/product/components/ProductFilter.jsx | 36 ++++++++---- .../product/components/ProductFilterDesktop.jsx | 67 ++++++++++++---------- 2 files changed, 61 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index 38e2d2c3..14eef0ba 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -96,12 +96,18 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr value={brand} onChange={(e) => setBrand(e.target.value)} > - - {brands.map((brand, index) => ( - - ))} + {brands.length > 0 ? ( + <> + + {brands.map((brand, index) => ( + + ))} + + ) : ( + + )} )} @@ -114,12 +120,18 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr value={category} onChange={(e) => setCategory(e.target.value)} > - - {categories.map((category, index) => ( - - ))} + {categories.length > 0 ? ( + <> + + {categories.map((category, index) => ( + + ))} + + ) : ( + + )}
diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index 582dabea..e84d6526 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -111,7 +111,6 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu return ( <> - {!router.pathname.includes('brands') && ( @@ -123,21 +122,25 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu - {brands.map((brand, index) => ( -
- -
- {brand.brand} - ({brand.qty}) -
-
-
- ))} + {brands && brands.length > 0 ? ( + brands.map((brand, index) => ( +
+ +
+ {brand.brand} + ({brand.qty}) +
+
+
+ )) + ) : ( +
Brands tidak tersedia
+ )}
@@ -153,21 +156,25 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu - {categories.map((category, index) => ( -
- -
+ {categories && categories.length > 0 ? ( + categories.map((category, index) => ( +
+ +
{category.name} ({category.qty})
-
-
- ))} + +
+ )) + ) : ( +
Kategori tidak tersedia
+ )} @@ -218,7 +225,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu - + {/* Ketersedian Stok @@ -236,7 +243,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu Ketersedian Stock
- + */}