From 87a004c0fcf256e1e92653767a630c01ad21ad5a Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Sat, 18 Nov 2023 11:33:28 +0700
Subject: add brand link di page search

---
 src/lib/product/components/ProductSearch.jsx | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 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 a4e9ecbb..29bb987e 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -20,6 +20,7 @@ import odooApi from '@/core/api/odooApi'
 import { formatCurrency } from '@/core/utils/formatValue'
 import axios from 'axios'
 import Skeleton from 'react-loading-skeleton'
+import { createSlug } from '@/core/utils/slug'
 
 const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null }) => {
   const router = useRouter()
@@ -87,13 +88,16 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
       const brand = await axios(
         `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=search&q=${search}`
       )
+      console.log('ini brand', brand)
       if (brand.data.length > 0) {
         setIsBrand(brand?.data[0])
       } else {
         setIsBrand(null)
       }
     }
-    checkIfBrand()
+    if (router.pathname.includes('search')) {
+      checkIfBrand()
+    }
   }, [q])
 
   const brands = []
@@ -362,11 +366,12 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
             {isBrand && isBrand.logo && (
               <div className='mb-3'>
                 <h1 className='text-2xl mb-2 font-semibold'>Brand Pencarian {q}</h1>
-                <Image
-                  src={isBrand?.logo}
-                  alt=''
-                  className='object-cover object-center h-[100px]'
-                />
+                <Link
+                  href={createSlug('/shop/brands/', isBrand.name, isBrand.id)}
+                  className='inline'
+                >
+                  <Image src={isBrand?.logo} alt='' className='object-cover object-center h-24' />
+                </Link>
               </div>
             )}
 
-- 
cgit v1.2.3

