From b8f5507cda2ede25ebc5433439168a8dadc71ddc Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 20 Oct 2023 10:26:15 +0700
Subject: fixing serach

---
 src/lib/product/components/ProductSearch.jsx | 9 +++++++--
 1 file changed, 7 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 bc69c9dd..af3d881f 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -26,18 +26,22 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
   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 } })
+  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)
   const [bannerPromotionFooter, setBannerPromotionFooter] = useState(null)
   const popup = useActive()
   const numRows = [30, 50, 80, 100]
-  const [brandValues, setBrand] = useState(query?.brand?.split(',') || [])
+  const [brandValues, setBrand] = useState(
+    !router.pathname.includes('brands') ? query.brand ? query.brand.split(',') : [] : []
+  )
   const [categoryValues, setCategory] = useState(query?.category?.split(',') || [])
   const [priceFrom, setPriceFrom] = useState(query?.priceFrom || null)
   const [priceTo, setPriceTo] = useState(query?.priceTo || null)
 
+  console.log('ini roiute', router.pathname.includes('brands'))
+
   const pageCount = Math.ceil(productSearch.data?.response.numFound / limit)
   const productStart = productSearch.data?.responseHeader.params.start
   const productRows = limit
@@ -466,6 +470,7 @@ const FilterChoicesComponent = ({
           <TagCloseButton onClick={() => handleDeleteFilter('brands', value)} />
         </Tag>
       ))}
+
       {categoryValues.map((value, index) => (
         <Tag size='lg' key={index} borderRadius='lg' variant='outline' colorScheme='gray'>
           <TagLabel>{value}</TagLabel>
-- 
cgit v1.2.3

