summaryrefslogtreecommitdiff
path: root/src/pages/index.jsx
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-07-23 09:42:57 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-07-23 09:42:57 +0700
commitaed8055fbef665984574bc98bb6223c1c54a821a (patch)
treefe795d141fb8d7e9404949e77c367f5a8a405937 /src/pages/index.jsx
parentd628ae7e520f01186e7ede2e06118d869ee7282f (diff)
<iman> marged develompent & category management
Diffstat (limited to 'src/pages/index.jsx')
-rw-r--r--src/pages/index.jsx35
1 files changed, 33 insertions, 2 deletions
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>