From 6b173eaf8a95432316822b1d41b084875adfbd83 Mon Sep 17 00:00:00 2001
From: "tri.susilo" <tri.susilo@altama.co.id>
Date: Wed, 8 May 2024 14:47:11 +0700
Subject: [agnes] - Feature category management

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

(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 08b64c13..253c3703 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -26,6 +26,8 @@ import ProductSearchSkeleton from './Skeleton/ProductSearchSkeleton';
 
 import SideBanner from '~/modules/side-banner';
 import FooterBanner from '~/modules/footer-banner';
+import CategorySection from './CategorySection';
+import { getIdFromSlug } from '@/core/utils/slug'
 
 const ProductSearch = ({
   query,
@@ -68,6 +70,10 @@ const ProductSearch = ({
   const productStart = productSearch.data?.responseHeader.params.start;
   const productRows = limit;
   const productFound = productSearch.data?.response.numFound;
+  const [dataCategories, setDataCategories] = useState([])
+
+  const categoryId = getIdFromSlug(prefixUrl)
+
 
   useEffect(() => {
     if (productFound == 0 && query.q && !spellings) {
@@ -116,6 +122,18 @@ const ProductSearch = ({
     }
   }, [q]);
 
+  useEffect(() => {
+    const loadCategories = async () => {
+     const getCategories = await odooApi('GET', '/api/v1/category/child?partner_id='+{categoryId})
+     if(getCategories){
+      setDataCategories(getCategories)
+     }
+    }
+    loadCategories()
+  }, [])
+  
+  console.log('Data Category : ', dataCategories)
+
   const brands = [];
   for (
     let i = 0;
@@ -409,7 +427,9 @@ const ProductSearch = ({
 
             <SideBanner />
           </div>
+
           <div className='w-9/12 pl-6'>
+            <CategorySection categories={dataCategories}/>
             {bannerPromotionHeader && bannerPromotionHeader?.image && (
               <div className='mb-3'>
                 <Image
-- 
cgit v1.2.3


From 6c79d14a11c8dba20778c0559230a406cd147cc7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 3 Jul 2024 08:34:16 +0700
Subject: <iman> update category management

---
 src/lib/product/components/ProductSearch.jsx | 7 ++-----
 1 file changed, 2 insertions(+), 5 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 253c3703..29cf94da 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -74,7 +74,6 @@ const ProductSearch = ({
 
   const categoryId = getIdFromSlug(prefixUrl)
 
-
   useEffect(() => {
     if (productFound == 0 && query.q && !spellings) {
       searchSpellApi({ query: query.q }).then((response) => {
@@ -121,18 +120,16 @@ const ProductSearch = ({
       checkIfBrand();
     }
   }, [q]);
-
+ 
   useEffect(() => {
     const loadCategories = async () => {
-     const getCategories = await odooApi('GET', '/api/v1/category/child?partner_id='+{categoryId})
+      const getCategories = await odooApi('GET', `/api/v1/category/child?parent_id=${categoryId}`) 
      if(getCategories){
       setDataCategories(getCategories)
      }
     }
     loadCategories()
   }, [])
-  
-  console.log('Data Category : ', dataCategories)
 
   const brands = [];
   for (
-- 
cgit v1.2.3


From d6b459b3ea396775fae25b44d34c8dc724379224 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 20 Jul 2024 11:45:41 +0700
Subject: <iman> update mobile view

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

(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 29cf94da..c4970b21 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -336,6 +336,7 @@ const ProductSearch = ({
               SpellingComponent
             )}
           </div>
+          <CategorySection categories={dataCategories}/>
 
           {productFound > 0 && (
             <div className='flex items-center gap-x-2 mb-5 justify-between'>
-- 
cgit v1.2.3


From 2e71abba4ca5b83cc1fec229d4d85961c4b56d71 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 25 Jul 2024 08:27:05 +0700
Subject: <iman> update category management

---
 src/lib/product/components/ProductSearch.jsx | 35 +++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 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 c4970b21..b5c1e87d 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -28,6 +28,7 @@ import SideBanner from '~/modules/side-banner';
 import FooterBanner from '~/modules/footer-banner';
 import CategorySection from './CategorySection';
 import { getIdFromSlug } from '@/core/utils/slug'
+import { data } from 'autoprefixer';
 
 const ProductSearch = ({
   query,
@@ -63,6 +64,7 @@ const ProductSearch = ({
   const [categoryValues, setCategory] = useState(
     query?.category?.split(',') || []
   );
+  
   const [priceFrom, setPriceFrom] = useState(query?.priceFrom || null);
   const [priceTo, setPriceTo] = useState(query?.priceTo || null);
 
@@ -71,6 +73,9 @@ const ProductSearch = ({
   const productRows = limit;
   const productFound = productSearch.data?.response.numFound;
   const [dataCategories, setDataCategories] = useState([])
+  const [dataCategoriesProduct, setDataCategoriesProduct] = useState([])
+  const dataId = []
+  // console.log("dataCategories",dataCategories)
 
   const categoryId = getIdFromSlug(prefixUrl)
 
@@ -103,7 +108,7 @@ const ProductSearch = ({
       });
     }
   }, [productFound, query, spellings]);
-
+  let id = []
   useEffect(() => {
     const checkIfBrand = async () => {
       const brand = await axios(
@@ -123,13 +128,37 @@ const ProductSearch = ({
  
   useEffect(() => {
     const loadCategories = async () => {
-      const getCategories = await odooApi('GET', `/api/v1/category/child?parent_id=${categoryId}`) 
+      const getCategories = await odooApi('GET', `/api/v1/category/child?parent_id=${categoryId}`)
      if(getCategories){
       setDataCategories(getCategories)
      }
     }
     loadCategories()
+
+    const loadProduct = async () => {
+      const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${categoryId}`)
+      console.log("getCategoriesId",getCategoriesId)
+     if(getCategoriesId){
+      setDataCategoriesProduct(getCategoriesId)
+     }
+    }
+    loadProduct()
   }, [])
+  collectIds(dataCategoriesProduct);
+
+// Fungsi rekursif untuk menambahkan ID dari kategori dan subkategori ke array dataId
+function collectIds(category) {
+  if (category && category.id) {
+    dataId.push(category.id);
+  }
+  if (Array.isArray(category.children)) {
+    for (const child of category.children) {
+      collectIds(child);
+    }
+  }
+}
+
+console.log("dataID",dataId)
 
   const brands = [];
   for (
@@ -275,7 +304,7 @@ const ProductSearch = ({
   };
 
   const isNotReadyStockPage = router.asPath !== '/shop/search?orderBy=stock';
-
+  console.log("query?.category?.split(',')",query.fq)
   return (
     <>
       <MobileView>
-- 
cgit v1.2.3


From 2c2885f57e9eb15e8c7d00c3a543a71c1d6ba83e Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 25 Jul 2024 14:04:43 +0700
Subject: <iman> update search handle for category

---
 src/lib/product/components/ProductSearch.jsx | 83 ++++++++++++++++++----------
 1 file changed, 53 insertions(+), 30 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 b5c1e87d..413f4fb2 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -42,9 +42,56 @@ const ProductSearch = ({
   const [search, setSearch] = useState(query?.q || '*');
   const [limit, setLimit] = useState(query?.limit || 30);
   const [orderBy, setOrderBy] = useState(router.query?.orderBy || 'popular');
+  const [finalQuery, setFinalQuery] = useState({});
+  const [queryFinal, setQueryFinal] = useState({});
+  const [dataCategoriesProduct, setDataCategoriesProduct] = useState([])
+  const categoryId = getIdFromSlug(prefixUrl)
   if (defaultBrand) query.brand = defaultBrand.toLowerCase();
+  useEffect(() => {
+    const loadProduct = async () => {
+      const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${categoryId}`);
+      if (getCategoriesId) {
+        setDataCategoriesProduct(getCategoriesId);
+      }
+    };
+    loadProduct();
+  }, [categoryId]);
+
+  const collectIds = (category) => {
+    const ids = [];
+    function recurse(cat) {
+      if (cat && cat.id) {
+        ids.push(cat.id);
+      }
+      if (Array.isArray(cat.children)) {
+        cat.children.forEach(recurse);
+      }
+    }
+    recurse(category);
+    return ids;
+  };
+
+  useEffect(() => {
+    const ids = collectIds(dataCategoriesProduct);
+    const newQuery = {
+      fq: `category_id_i:(${ids.join(' OR ')})`,
+      page: 1,
+      brand : router.query.brand? router.query.brand : '',
+    };
+    setFinalQuery(newQuery);
+  }, [dataCategoriesProduct]);
+
+  useEffect(() => {
+    if (prefixUrl.includes('category')) {
+      setQueryFinal({ ...finalQuery, q, limit, orderBy });
+      // setQueryFinal({ ...query, q, limit, orderBy });
+    } else {
+      setQueryFinal({ ...query, q, limit, orderBy });
+    }
+  }, [prefixUrl, finalQuery, q, limit, orderBy]);
+
   const { productSearch } = useProductSearch({
-    query: { ...query, q, limit, orderBy },
+    query: queryFinal,
     operation: 'AND',
   });
   const [products, setProducts] = useState(null);
@@ -73,12 +120,7 @@ const ProductSearch = ({
   const productRows = limit;
   const productFound = productSearch.data?.response.numFound;
   const [dataCategories, setDataCategories] = useState([])
-  const [dataCategoriesProduct, setDataCategoriesProduct] = useState([])
-  const dataId = []
-  // console.log("dataCategories",dataCategories)
-
-  const categoryId = getIdFromSlug(prefixUrl)
-
+  
   useEffect(() => {
     if (productFound == 0 && query.q && !spellings) {
       searchSpellApi({ query: query.q }).then((response) => {
@@ -134,31 +176,10 @@ const ProductSearch = ({
      }
     }
     loadCategories()
-
-    const loadProduct = async () => {
-      const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${categoryId}`)
-      console.log("getCategoriesId",getCategoriesId)
-     if(getCategoriesId){
-      setDataCategoriesProduct(getCategoriesId)
-     }
-    }
-    loadProduct()
   }, [])
-  collectIds(dataCategoriesProduct);
 
-// Fungsi rekursif untuk menambahkan ID dari kategori dan subkategori ke array dataId
-function collectIds(category) {
-  if (category && category.id) {
-    dataId.push(category.id);
-  }
-  if (Array.isArray(category.children)) {
-    for (const child of category.children) {
-      collectIds(child);
-    }
-  }
-}
+  
 
-console.log("dataID",dataId)
 
   const brands = [];
   for (
@@ -304,7 +325,9 @@ console.log("dataID",dataId)
   };
 
   const isNotReadyStockPage = router.asPath !== '/shop/search?orderBy=stock';
-  console.log("query?.category?.split(',')",query.fq)
+  
+  
+
   return (
     <>
       <MobileView>
-- 
cgit v1.2.3


From 4758a0989f2ec0d79e1c5e3a3d42c249f28a9e72 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 26 Jul 2024 14:13:20 +0700
Subject: <iman> update code category management

---
 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 413f4fb2..cd7cda9f 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -74,7 +74,7 @@ const ProductSearch = ({
   useEffect(() => {
     const ids = collectIds(dataCategoriesProduct);
     const newQuery = {
-      fq: `category_id_i:(${ids.join(' OR ')})`,
+      fq: `category_id_ids:(${ids.join(' OR ')})`,
       page: 1,
       brand : router.query.brand? router.query.brand : '',
     };
-- 
cgit v1.2.3


From e5a01976cb665b824b2ad6426a2c52a5bd0964e6 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 27 Jul 2024 08:27:54 +0700
Subject: <iman> add feature category lob

---
 src/lib/product/components/ProductSearch.jsx | 5 +++--
 1 file changed, 3 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 cd7cda9f..735ef58e 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -78,8 +78,9 @@ const ProductSearch = ({
       page: 1,
       brand : router.query.brand? router.query.brand : '',
     };
+    console.log("newQuery",newQuery)
     setFinalQuery(newQuery);
-  }, [dataCategoriesProduct]);
+  }, [dataCategoriesProduct, prefixUrl, prefixUrl, finalQuery, q, limit, orderBy]);
 
   useEffect(() => {
     if (prefixUrl.includes('category')) {
@@ -178,7 +179,7 @@ const ProductSearch = ({
     loadCategories()
   }, [])
 
-  
+  console.log("queryFinal", queryFinal)
 
 
   const brands = [];
-- 
cgit v1.2.3


From f1910544cf6df50bcb175b66b604f5903f6ae3fa Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 27 Jul 2024 13:34:00 +0700
Subject: <iman> update category management for lob

---
 src/lib/product/components/ProductSearch.jsx | 98 +++++++++++++++++++++-------
 1 file changed, 76 insertions(+), 22 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 735ef58e..2da84d63 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -37,6 +37,7 @@ const ProductSearch = ({
   brand = null,
 }) => {
   const router = useRouter();
+   
   const { page = 1 } = query;
   const [q, setQ] = useState(query?.q || '*');
   const [search, setSearch] = useState(query?.q || '*');
@@ -45,18 +46,35 @@ const ProductSearch = ({
   const [finalQuery, setFinalQuery] = useState({});
   const [queryFinal, setQueryFinal] = useState({});
   const [dataCategoriesProduct, setDataCategoriesProduct] = useState([])
+  const [dataCategoriesLob, setDataCategoriesLob] = useState([])
   const categoryId = getIdFromSlug(prefixUrl)
+  console.log("categoryId",categoryId ) 
+  const [data, setData] = useState([])
+  const [dataLob, setDataLob] = useState([]);
   if (defaultBrand) query.brand = defaultBrand.toLowerCase();
+  const dataIdCategories = []
   useEffect(() => {
-    const loadProduct = async () => {
-      const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${categoryId}`);
-      if (getCategoriesId) {
-        setDataCategoriesProduct(getCategoriesId);
-      }
-    };
-    loadProduct();
+    if(prefixUrl.includes('category')){
+      const loadProduct = async () => {
+        const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${categoryId}`);
+        if (getCategoriesId) {
+          setDataCategoriesProduct(getCategoriesId);
+        }
+      };
+      loadProduct();
+    }else if(prefixUrl.includes('lob')){
+      const loadProduct = async () => {
+        const lobData = await odooApi('GET', `/api/v1/lob_homepage?lob_id=${categoryId}`);
+        console.log("lobData",lobData ) 
+        if (lobData) {
+          setDataLob(lobData);
+        }
+      };
+      loadProduct();
+      console.log("dataLob",dataLob ) 
+    }
   }, [categoryId]);
-
+  
   const collectIds = (category) => {
     const ids = [];
     function recurse(cat) {
@@ -70,26 +88,61 @@ const ProductSearch = ({
     recurse(category);
     return ids;
   };
-
+  
   useEffect(() => {
-    const ids = collectIds(dataCategoriesProduct);
-    const newQuery = {
-      fq: `category_id_ids:(${ids.join(' OR ')})`,
-      page: 1,
-      brand : router.query.brand? router.query.brand : '',
-    };
-    console.log("newQuery",newQuery)
-    setFinalQuery(newQuery);
-  }, [dataCategoriesProduct, prefixUrl, prefixUrl, finalQuery, q, limit, orderBy]);
+    if(prefixUrl.includes('category')){
+      const ids = collectIds(dataCategoriesProduct);
+      const newQuery = {
+        fq: `category_id_ids:(${ids.join(' OR ')})`,
+        page,
+        brand : router.query.brand? router.query.brand : '',
+        category : router.query.category? router.query.category : '',
+      };
+      setFinalQuery(newQuery);
+    } else if (prefixUrl.includes('lob')){
+      console.log("prefixUrl",prefixUrl) 
+      const fetchCategoryData = async () => {
+        if (dataLob[0]?.categoryIds) {
+          console.log("dataLob[0]?.categoryIds",dataLob[0]?.categoryIds) 
+          for (const cate of dataLob[0].categoryIds) {
+            console.log("cate",cate) 
+            const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${cate.id}`);
+            console.log("getCategoriesId",getCategoriesId) 
+            if (getCategoriesId) {
+              const ids = collectIds(getCategoriesId);
+              console.log("ids",ids) 
+              dataIdCategories.push(ids)
+              console.log("dataIdCategories",dataIdCategories) 
+            }
+          }
+          
+          console.log("dataIdCategories2",dataIdCategories) 
+          // setData(dataIdCategories)
+          // console.log("data",data) 
+          const mergedArray = dataIdCategories.flat();
+          console.log("mergedArray",mergedArray) 
+          const newQuery = {
+            fq: `category_id_ids:(${mergedArray.join(' OR ')})`,
+            page,
+            brand : router.query.brand? router.query.brand : '',
+            category : router.query.category? router.query.category : '',
+          };
+          console.log("newQuery",newQuery) 
+          setFinalQuery(newQuery);
+          console.log("final query",finalQuery)
+        }
+      };
+      fetchCategoryData();
+    }
+  }, [dataCategoriesProduct, dataLob]);
 
   useEffect(() => {
-    if (prefixUrl.includes('category')) {
+    if (prefixUrl.includes('category') || prefixUrl.includes('lob')) {
       setQueryFinal({ ...finalQuery, q, limit, orderBy });
-      // setQueryFinal({ ...query, q, limit, orderBy });
     } else {
       setQueryFinal({ ...query, q, limit, orderBy });
     }
-  }, [prefixUrl, finalQuery, q, limit, orderBy]);
+  }, [prefixUrl,dataCategoriesProduct, query, finalQuery]);
 
   const { productSearch } = useProductSearch({
     query: queryFinal,
@@ -179,7 +232,8 @@ const ProductSearch = ({
     loadCategories()
   }, [])
 
-  console.log("queryFinal", queryFinal)
+  // console.log("query asal ", query)
+  // console.log("queryFinal", queryFinal)
 
 
   const brands = [];
-- 
cgit v1.2.3


From 556e7e226a2043d43bc55bf0ff2118294bb9f330 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 29 Jul 2024 13:32:39 +0700
Subject: <iman> update lob category

---
 src/lib/product/components/ProductSearch.jsx | 54 +++++++++++++---------------
 1 file changed, 24 insertions(+), 30 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 2da84d63..12e3b358 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -27,6 +27,7 @@ import ProductSearchSkeleton from './Skeleton/ProductSearchSkeleton';
 import SideBanner from '~/modules/side-banner';
 import FooterBanner from '~/modules/footer-banner';
 import CategorySection from './CategorySection';
+import LobSectionCategory from './LobSectionCategory';
 import { getIdFromSlug } from '@/core/utils/slug'
 import { data } from 'autoprefixer';
 
@@ -48,7 +49,6 @@ const ProductSearch = ({
   const [dataCategoriesProduct, setDataCategoriesProduct] = useState([])
   const [dataCategoriesLob, setDataCategoriesLob] = useState([])
   const categoryId = getIdFromSlug(prefixUrl)
-  console.log("categoryId",categoryId ) 
   const [data, setData] = useState([])
   const [dataLob, setDataLob] = useState([]);
   if (defaultBrand) query.brand = defaultBrand.toLowerCase();
@@ -64,14 +64,14 @@ const ProductSearch = ({
       loadProduct();
     }else if(prefixUrl.includes('lob')){
       const loadProduct = async () => {
-        const lobData = await odooApi('GET', `/api/v1/lob_homepage?lob_id=${categoryId}`);
-        console.log("lobData",lobData ) 
+        const lobData = await odooApi('GET', `/api/v1/lob_homepage/${categoryId}/category_id`);
+         
         if (lobData) {
           setDataLob(lobData);
         }
       };
       loadProduct();
-      console.log("dataLob",dataLob ) 
+      
     }
   }, [categoryId]);
   
@@ -100,36 +100,27 @@ const ProductSearch = ({
       };
       setFinalQuery(newQuery);
     } else if (prefixUrl.includes('lob')){
-      console.log("prefixUrl",prefixUrl) 
+      
       const fetchCategoryData = async () => {
         if (dataLob[0]?.categoryIds) {
-          console.log("dataLob[0]?.categoryIds",dataLob[0]?.categoryIds) 
+          
           for (const cate of dataLob[0].categoryIds) {
-            console.log("cate",cate) 
-            const getCategoriesId = await odooApi('GET', `/api/v1/category/numFound?parent_id=${cate.id}`);
-            console.log("getCategoriesId",getCategoriesId) 
-            if (getCategoriesId) {
-              const ids = collectIds(getCategoriesId);
-              console.log("ids",ids) 
-              dataIdCategories.push(ids)
-              console.log("dataIdCategories",dataIdCategories) 
-            }
+           
+            dataIdCategories.push(cate.childId)
           }
           
-          console.log("dataIdCategories2",dataIdCategories) 
-          // setData(dataIdCategories)
-          // console.log("data",data) 
+        
           const mergedArray = dataIdCategories.flat();
-          console.log("mergedArray",mergedArray) 
+         
           const newQuery = {
             fq: `category_id_ids:(${mergedArray.join(' OR ')})`,
             page,
             brand : router.query.brand? router.query.brand : '',
             category : router.query.category? router.query.category : '',
           };
-          console.log("newQuery",newQuery) 
+       
           setFinalQuery(newQuery);
-          console.log("final query",finalQuery)
+         
         }
       };
       fetchCategoryData();
@@ -223,17 +214,18 @@ const ProductSearch = ({
   }, [q]);
  
   useEffect(() => {
-    const loadCategories = async () => {
-      const getCategories = await odooApi('GET', `/api/v1/category/child?parent_id=${categoryId}`)
-     if(getCategories){
-      setDataCategories(getCategories)
-     }
+    if(prefixUrl.includes('category')){
+      const loadCategories = async () => {
+        const getCategories = await odooApi('GET', `/api/v1/category/child?parent_id=${categoryId}`)
+       if(getCategories){
+        setDataCategories(getCategories)
+       }
+      }
+      loadCategories()
     }
-    loadCategories()
   }, [])
 
-  // console.log("query asal ", query)
-  // console.log("queryFinal", queryFinal)
+
 
 
   const brands = [];
@@ -381,7 +373,7 @@ const ProductSearch = ({
 
   const isNotReadyStockPage = router.asPath !== '/shop/search?orderBy=stock';
   
-  
+  console.log("finalQuery",finalQuery)
 
   return (
     <>
@@ -443,6 +435,7 @@ const ProductSearch = ({
               SpellingComponent
             )}
           </div>
+          <LobSectionCategory categories={dataLob}/>
           <CategorySection categories={dataCategories}/>
 
           {productFound > 0 && (
@@ -534,6 +527,7 @@ const ProductSearch = ({
           </div>
 
           <div className='w-9/12 pl-6'>
+            <LobSectionCategory categories={dataLob}/>
             <CategorySection categories={dataCategories}/>
             {bannerPromotionHeader && bannerPromotionHeader?.image && (
               <div className='mb-3'>
-- 
cgit v1.2.3


From 7c2a69c9b48c1930dc3f7cbef20d6479b3047ca2 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 29 Jul 2024 17:13:30 +0700
Subject: <iman> update category lob

---
 src/lib/product/components/ProductSearch.jsx | 35 +++++++++++++++++-----------
 1 file changed, 21 insertions(+), 14 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 12e3b358..7ab6b8af 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -38,11 +38,10 @@ const ProductSearch = ({
   brand = null,
 }) => {
   const router = useRouter();
-   
   const { page = 1 } = query;
   const [q, setQ] = useState(query?.q || '*');
   const [search, setSearch] = useState(query?.q || '*');
-  const [limit, setLimit] = useState(query?.limit || 30);
+  const [limit, setLimit] = useState(router.query?.limit || 30);
   const [orderBy, setOrderBy] = useState(router.query?.orderBy || 'popular');
   const [finalQuery, setFinalQuery] = useState({});
   const [queryFinal, setQueryFinal] = useState({});
@@ -94,9 +93,13 @@ const ProductSearch = ({
       const ids = collectIds(dataCategoriesProduct);
       const newQuery = {
         fq: `category_id_ids:(${ids.join(' OR ')})`,
-        page,
+        page : router.query.page? router.query.page : 1,
         brand : router.query.brand? router.query.brand : '',
         category : router.query.category? router.query.category : '',
+        priceFrom : router.query.priceFrom? router.query.priceFrom : '',
+        priceTo : router.query.priceTo? router.query.priceTo : '',
+        limit : router.query.limit? router.query.limit : '',
+        orderBy : router.query.orderBy? router.query.orderBy : ''
       };
       setFinalQuery(newQuery);
     } else if (prefixUrl.includes('lob')){
@@ -114,9 +117,13 @@ const ProductSearch = ({
          
           const newQuery = {
             fq: `category_id_ids:(${mergedArray.join(' OR ')})`,
-            page,
-            brand : router.query.brand? router.query.brand : '',
             category : router.query.category? router.query.category : '',
+            page : router.query.page? router.query.page : 1,
+            brand : router.query.brand? router.query.brand : '',
+            priceFrom : router.query.priceFrom? router.query.priceFrom : '',
+            priceTo : router.query.priceTo? router.query.priceTo : '',
+            limit : router.query.limit? router.query.limit : '',
+            orderBy : router.query.orderBy? router.query.orderBy : ''
           };
        
           setFinalQuery(newQuery);
@@ -148,17 +155,17 @@ const ProductSearch = ({
   const numRows = [30, 50, 80, 100];
   const [brandValues, setBrand] = useState(
     !router.pathname.includes('brands')
-      ? query.brand
-        ? query.brand.split(',')
+      ? router.query.brand
+        ? router.query.brand.split(',')
         : []
       : []
   );
   const [categoryValues, setCategory] = useState(
-    query?.category?.split(',') || []
+    router.query?.category?.split(',') || router.query?.category?.split(',')
   );
   
-  const [priceFrom, setPriceFrom] = useState(query?.priceFrom || null);
-  const [priceTo, setPriceTo] = useState(query?.priceTo || null);
+  const [priceFrom, setPriceFrom] = useState(router.query?.priceFrom || null);
+  const [priceTo, setPriceTo] = useState(router.query?.priceTo || null);
 
   const pageCount = Math.ceil(productSearch.data?.response.numFound / limit);
   const productStart = productSearch.data?.responseHeader.params.start;
@@ -373,8 +380,6 @@ const ProductSearch = ({
 
   const isNotReadyStockPage = router.asPath !== '/shop/search?orderBy=stock';
   
-  console.log("finalQuery",finalQuery)
-
   return (
     <>
       <MobileView>
@@ -476,7 +481,8 @@ const ProductSearch = ({
           <Pagination
             pageCount={pageCount}
             currentPage={parseInt(page)}
-            url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+            // url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+            url={prefixUrl.includes('category') || prefixUrl.includes('lob')? `${prefixUrl}?${toQuery(_.omit(finalQuery, ['page']))}` : `${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
             className='mt-6 mb-2'
           />
 
@@ -665,7 +671,8 @@ const ProductSearch = ({
               <Pagination
                 pageCount={pageCount}
                 currentPage={parseInt(page)}
-                url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+                // url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+                url={prefixUrl.includes('category') || prefixUrl.includes('lob')? `${prefixUrl}?${toQuery(_.omit(finalQuery, ['page']))}` : `${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
                 className='!justify-end'
               />
             </div>
-- 
cgit v1.2.3


From 593c508bb87451a985a5aec7e9d7bde45b18074b Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 30 Jul 2024 09:53:35 +0700
Subject: <iman> update category lob

---
 src/lib/product/components/ProductSearch.jsx | 9 ++++-----
 1 file changed, 4 insertions(+), 5 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 7ab6b8af..d4c5a308 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -379,7 +379,6 @@ const ProductSearch = ({
   };
 
   const isNotReadyStockPage = router.asPath !== '/shop/search?orderBy=stock';
-  
   return (
     <>
       <MobileView>
@@ -481,8 +480,8 @@ const ProductSearch = ({
           <Pagination
             pageCount={pageCount}
             currentPage={parseInt(page)}
-            // url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
-            url={prefixUrl.includes('category') || prefixUrl.includes('lob')? `${prefixUrl}?${toQuery(_.omit(finalQuery, ['page']))}` : `${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+            url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+            // url={prefixUrl.includes('category') || prefixUrl.includes('lob')? `${prefixUrl}?${toQuery(_.omit(finalQuery, ['page']))}` : `${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
             className='mt-6 mb-2'
           />
 
@@ -671,8 +670,8 @@ const ProductSearch = ({
               <Pagination
                 pageCount={pageCount}
                 currentPage={parseInt(page)}
-                // url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
-                url={prefixUrl.includes('category') || prefixUrl.includes('lob')? `${prefixUrl}?${toQuery(_.omit(finalQuery, ['page']))}` : `${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+                url={`${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
+                // url={prefixUrl.includes('category') || prefixUrl.includes('lob')? `${prefixUrl}?${toQuery(_.omit(finalQuery, ['page']))}` : `${prefixUrl}?${toQuery(_.omit(query, ['page']))}`}
                 className='!justify-end'
               />
             </div>
-- 
cgit v1.2.3


From c92b47f81b4ea90f799810555395af7afcfa5a4d Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 30 Jul 2024 14:47:28 +0700
Subject: <iman> update category management

---
 src/lib/product/components/ProductSearch.jsx | 4 +++-
 1 file changed, 3 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 d4c5a308..09534a5d 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -249,6 +249,7 @@ const ProductSearch = ({
       brands.push({ brand, qty });
     }
   }
+  
 
   const categories = [];
   for (
@@ -263,6 +264,7 @@ const ProductSearch = ({
       categories.push({ name, qty });
     }
   }
+  
 
   const orderOptions = [
     { value: 'price-asc', label: 'Harga Terendah' },
@@ -340,7 +342,7 @@ const ProductSearch = ({
       q: router.query.q,
       orderBy: orderBy,
       brand: brandValues.join(','),
-      category: categoryValues.join(','),
+      category: categoryValues?.join(','),
       priceFrom,
       priceTo,
     };
-- 
cgit v1.2.3

