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

