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/pages/index.jsx | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

(limited to 'src/pages/index.jsx')

diff --git a/src/pages/index.jsx b/src/pages/index.jsx
index 8af963fb..d2f6073b 100644
--- a/src/pages/index.jsx
+++ b/src/pages/index.jsx
@@ -1,5 +1,5 @@
 import dynamic from 'next/dynamic';
-import { useRef } from 'react';
+import { useEffect, useRef, useState } from 'react';
 
 import { HeroBannerSkeleton } from '@/components/skeleton/BannerSkeleton';
 import { PopularProductSkeleton } from '@/components/skeleton/PopularProductSkeleton';
@@ -11,6 +11,10 @@ import { FlashSaleSkeleton } from '@/lib/flashSale/skeleton/FlashSaleSkeleton';
 import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBrandSkeleton';
 import PromotinProgram from '@/lib/promotinProgram/components/HomePage';
 import PagePopupIformation from '~/modules/popup-information';
+import CategoryPilihan from '../lib/home/components/CategoryPilihan';
+// import CategoryDynamic from '../lib/home/components/CategoryDynamic';
+import odooApi from '@/core/api/odooApi';
+import { getIdFromSlug } from '@/core/utils/slug'
 import useProductDetail from '~/modules/product-detail/stores/useProductDetail';
 import { getAuth } from '~/libs/auth';
 
@@ -54,12 +58,21 @@ const BannerSection = dynamic(() =>
 const CategoryHomeId = dynamic(() =>
   import('@/lib/home/components/CategoryHomeId')
 );
+
+const CategoryDynamic = dynamic(() =>
+  import('@/lib/home/components/CategoryDynamic')
+);
+
+const CategoryDynamicMobile = dynamic(() =>
+  import('@/lib/home/components/CategoryDynamicMobile')
+);
+
 const CustomerReviews = dynamic(() =>
   import('@/lib/review/components/CustomerReviews')
 );
 const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList'));
 
-export default function Home() {
+export default function Home({categoryId}) {
   const bannerRef = useRef(null);
   const wrapperRef = useRef(null);
 
@@ -70,6 +83,18 @@ export default function Home() {
       bannerRef.current?.querySelector(':first-child')?.clientHeight + 'px';
   };
 
+  const [dataCategories, setDataCategories] = useState([])
+
+  useEffect(() => {
+    const loadCategories = async () => {
+     const getCategories = await odooApi('GET', '/api/v1/category/child?partner_id='+{categoryId})
+     if(getCategories){
+      setDataCategories(getCategories)
+     }
+    }
+    loadCategories()
+  }, [])
+
   return (
     <BasicLayout>
       <Seo
@@ -117,6 +142,8 @@ export default function Home() {
               </>
             )}
             <PromotinProgram />
+            <CategoryPilihan categories={dataCategories}/>
+            <CategoryDynamic/>
             <CategoryHomeId />
             <BannerSection />
             <CustomerReviews />
@@ -150,6 +177,10 @@ export default function Home() {
           <DelayRender renderAfter={600}>
             <PromotinProgram />
           </DelayRender>
+          <DelayRender renderAfter={600}>
+            <CategoryPilihan categories={dataCategories}/>
+            <CategoryDynamicMobile/>
+          </DelayRender>
           <DelayRender renderAfter={800}>
             <PopularProduct />
           </DelayRender>
-- 
cgit v1.2.3

