From aed8055fbef665984574bc98bb6223c1c54a821a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 23 Jul 2024 09:42:57 +0700
Subject: <iman> marged develompent & category management

---
 src/lib/product/components/ProductSearch.jsx | 18 ++++++++++++++++++
 1 file changed, 18 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 b1a5d409..34018ffe 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,9 @@ 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) {
@@ -115,6 +120,16 @@ const ProductSearch = ({
       checkIfBrand();
     }
   }, [q]);
+ 
+  useEffect(() => {
+    const loadCategories = async () => {
+      const getCategories = await odooApi('GET', `/api/v1/category/child?parent_id=${categoryId}`) 
+     if(getCategories){
+      setDataCategories(getCategories)
+     }
+    }
+    loadCategories()
+  }, [])
 
   const brands = [];
   for (
@@ -323,6 +338,7 @@ const ProductSearch = ({
               SpellingComponent
             )}
           </div>
+          <CategorySection categories={dataCategories}/>
 
           {productFound > 0 && (
             <div className='flex items-center gap-x-2 mb-5 justify-between'>
@@ -411,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

