From 85e0a7e47db518fb5fb2531b2ea7c6d50408875f Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 20 Oct 2023 14:02:51 +0700
Subject: logo brand di page brand

---
 src/lib/product/components/ProductSearch.jsx | 41 ++++++++++++++--------------
 1 file changed, 21 insertions(+), 20 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 a4e3d872..630e3a74 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -19,14 +19,17 @@ import { HStack, Image, Tag, TagCloseButton, TagLabel } from '@chakra-ui/react'
 import odooApi from '@/core/api/odooApi'
 import { formatCurrency } from '@/core/utils/formatValue'
 
-const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
+const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null }) => {
   const router = useRouter()
   const { page = 1 } = query
   const [q, setQ] = useState(query?.q || '*')
   const [limit, setLimit] = useState(query?.limit || 30)
   const [orderBy, setOrderBy] = useState(router.query?.orderBy || 'popular')
   if (defaultBrand) query.brand = defaultBrand.toLowerCase()
-  const { productSearch } = useProductSearch({ query: { ...query, q, limit, orderBy } , operation :  router?.pathname?.includes('brands') ? 'OR' : 'AND' })
+  const { productSearch } = useProductSearch({
+    query: { ...query, q, limit, orderBy },
+    operation: router?.pathname?.includes('brands') ? 'OR' : 'AND'
+  })
   const [products, setProducts] = useState(null)
   const [spellings, setSpellings] = useState(null)
   const [bannerPromotionHeader, setBannerPromotionHeader] = useState(null)
@@ -34,7 +37,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
   const popup = useActive()
   const numRows = [30, 50, 80, 100]
   const [brandValues, setBrand] = useState(
-    !router.pathname.includes('brands') ? query.brand ? query.brand.split(',') : [] : []
+    !router.pathname.includes('brands') ? (query.brand ? query.brand.split(',') : []) : []
   )
   const [categoryValues, setCategory] = useState(query?.category?.split(',') || [])
   const [priceFrom, setPriceFrom] = useState(query?.priceFrom || null)
@@ -87,15 +90,6 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
       brands.push({ brand, qty })
     }
   }
-  /*const brandsList = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter(
-    (value, index) => {
-      if (index % 2 === 0) {
-        const brand = value
-        const qty = index + 1
-        brands.push({ brand, qty })
-      }
-    }
-  )*/
 
   const categories = []
   for (let i = 0; i < productSearch.data?.facetCounts?.facetFields?.categoryName.length; i += 2) {
@@ -106,14 +100,6 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
     }
   }
 
-  /*const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter(
-    (value, index) => {
-      if (index % 2 === 0) {
-        return true
-      }
-    }
-  )*/
-
   const orderOptions = [
     { value: 'price-asc', label: 'Harga Terendah' },
     { value: 'price-desc', label: 'Harga Tertinggi' },
@@ -309,6 +295,21 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
       <DesktopView>
         <div className='container mx-auto flex mb-3'>
           <div className='w-3/12'>
+            <div className='p-4'>
+              <div className='text-caption-1 text-gray_r-11 mb-2'>Produk dari brand:</div>
+              {brand?.data?.logo && (
+                <Image
+                  src={brand?.data?.logo}
+                  alt={brand?.data?.name}
+                  className='w-32 p-2 border borde-gray_r-6 rounded'
+                />
+              )}
+              {!brand?.data?.logo && (
+                <div className='bg-danger-500 text-white text-center text-body-1 py-2 px-4 rounded w-fit'>
+                  {brand?.data?.name}
+                </div>
+              )}
+            </div>
             <ProductFilterDesktop
               brands={brands || []}
               categories={categories || []}
-- 
cgit v1.2.3

