From 8d2d384509cd21fb76aeec76d82f362995e4851e Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Mon, 23 Oct 2023 15:40:04 +0700
Subject: bugs fix query solr filter brand dan category

---
 src/lib/product/components/ProductSearch.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 d094a25b..79df93f4 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -28,7 +28,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
   if (defaultBrand) query.brand = defaultBrand.toLowerCase()
   const { productSearch } = useProductSearch({
     query: { ...query, q, limit, orderBy },
-    operation: 'OR' 
+    operation: 'AND' 
   })
   const [products, setProducts] = useState(null)
   const [spellings, setSpellings] = useState(null)
-- 
cgit v1.2.3


From 84d81890283155056c26058df65939f4837b14b4 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Mon, 23 Oct 2023 15:48:06 +0700
Subject: CR UI - change label if product not found

---
 src/lib/product/components/ProductSearch.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 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 79df93f4..5fc75930 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -28,7 +28,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
   if (defaultBrand) query.brand = defaultBrand.toLowerCase()
   const { productSearch } = useProductSearch({
     query: { ...query, q, limit, orderBy },
-    operation: 'AND' 
+    operation: 'AND'
   })
   const [products, setProducts] = useState(null)
   const [spellings, setSpellings] = useState(null)
@@ -148,7 +148,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
   const SpellingComponent = useMemo(() => {
     return (
       <>
-        Mungkin yang anda cari{' '}
+        {spellings?.length > 0 ? <>Mungkin yang anda cari </> : <>Produk yang anda tidak ada</>}
         {spellings?.map((spelling, i) => (
           <Link href={`/shop/search?q=${spelling}`} key={i} className='inline'>
             {spelling}
-- 
cgit v1.2.3


From 7c08e60acc68f4fbd3ff6af756aeae7c1e7b866c Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 24 Oct 2023 10:02:44 +0700
Subject: change label

---
 src/lib/product/components/ProductSearch.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 5fc75930..3740d264 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -148,7 +148,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
   const SpellingComponent = useMemo(() => {
     return (
       <>
-        {spellings?.length > 0 ? <>Mungkin yang anda cari </> : <>Produk yang anda tidak ada</>}
+        {spellings?.length > 0 ? <>Mungkin yang anda cari </> : <>Produk yang cari anda tidak ada</>}
         {spellings?.map((spelling, i) => (
           <Link href={`/shop/search?q=${spelling}`} key={i} className='inline'>
             {spelling}
-- 
cgit v1.2.3


From 51726bd7e8e69535590d70327ebd340ffaf96abd Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 25 Oct 2023 09:50:46 +0700
Subject: show brand logo di page search

---
 src/lib/product/components/ProductSearch.jsx | 36 +++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

(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 3740d264..50936d9a 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -18,6 +18,8 @@ import whatsappUrl from '@/core/utils/whatsappUrl'
 import { HStack, Image, Tag, TagCloseButton, TagLabel } from '@chakra-ui/react'
 import odooApi from '@/core/api/odooApi'
 import { formatCurrency } from '@/core/utils/formatValue'
+import axios from 'axios'
+import Skeleton from 'react-loading-skeleton'
 
 const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null }) => {
   const router = useRouter()
@@ -34,6 +36,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
   const [spellings, setSpellings] = useState(null)
   const [bannerPromotionHeader, setBannerPromotionHeader] = useState(null)
   const [bannerPromotionFooter, setBannerPromotionFooter] = useState(null)
+  const [isBrand, setIsBrand] = useState(null)
   const popup = useActive()
   const numRows = [30, 50, 80, 100]
   const [brandValues, setBrand] = useState(
@@ -78,6 +81,22 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
     }
   }, [productFound, query, spellings])
 
+  useEffect(() => {
+    const checkIfBrand = async () => {
+      const brand = await axios(
+        `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=search&q=${q}`
+      )
+      if (brand.data.length > 0) {
+        brand.data.map((brand) => {
+          if (brand.name.toLowerCase() === q.toLowerCase()) {
+            setIsBrand(brand)
+          }
+        })
+      }
+    }
+    checkIfBrand()
+  }, [q])
+
   const brands = []
   for (
     let i = 0;
@@ -148,7 +167,11 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
   const SpellingComponent = useMemo(() => {
     return (
       <>
-        {spellings?.length > 0 ? <>Mungkin yang anda cari </> : <>Produk yang cari anda tidak ada</>}
+        {spellings?.length > 0 ? (
+          <>Mungkin yang anda cari </>
+        ) : (
+          <>Produk yang cari anda tidak ada</>
+        )}
         {spellings?.map((spelling, i) => (
           <Link href={`/shop/search?q=${spelling}`} key={i} className='inline'>
             {spelling}
@@ -331,6 +354,17 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
               </div>
             )}
 
+            {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]'
+                />
+              </div>
+            )}
+
             <h1 className='text-2xl mb-2 font-semibold'>Hasil Pencarian</h1>
             <FilterChoicesComponent
               brandValues={brandValues}
-- 
cgit v1.2.3


From 0a1413aec32fddc433a34bf7d03d8681dedc266d Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Mon, 30 Oct 2023 09:30:25 +0700
Subject: show brand logo in page search if search is brand

---
 src/lib/product/components/ProductSearch.jsx | 9 ++-------
 1 file changed, 2 insertions(+), 7 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 50936d9a..190d026b 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -86,13 +86,8 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
       const brand = await axios(
         `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=search&q=${q}`
       )
-      if (brand.data.length > 0) {
-        brand.data.map((brand) => {
-          if (brand.name.toLowerCase() === q.toLowerCase()) {
-            setIsBrand(brand)
-          }
-        })
-      }
+      setIsBrand(brand?.data[0])
+     
     }
     checkIfBrand()
   }, [q])
-- 
cgit v1.2.3

