diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-23 14:46:42 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-23 14:46:42 +0700 |
| commit | f6e0632292b1600341fccfd9d14c1ffe1be0f309 (patch) | |
| tree | 3df57a154e846f691b69d203dce941267f498a39 | |
| parent | b1341b76e94da9e64549768646bb54d2836976d0 (diff) | |
<iman> update error code
| -rw-r--r-- | src/pages/index.jsx | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/pages/index.jsx b/src/pages/index.jsx index cdbe0dd0..578c4e2d 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,6 +1,5 @@ import dynamic from 'next/dynamic'; import { useEffect, useRef, useState } from 'react'; - import { HeroBannerSkeleton } from '@/components/skeleton/BannerSkeleton'; import { PopularProductSkeleton } from '@/components/skeleton/PopularProductSkeleton'; import Seo from '@/core/components/Seo'; @@ -12,9 +11,8 @@ import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBran 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 { getAuth } from '~/libs/auth'; const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout') @@ -45,6 +43,11 @@ const FlashSale = dynamic( loading: () => <FlashSaleSkeleton />, } ); + +const ProgramPromotion = dynamic(() => + import('@/lib/home/components/PromotionProgram') +); + const BannerSection = dynamic(() => import('@/lib/home/components/BannerSection') ); @@ -65,17 +68,18 @@ const CustomerReviews = dynamic(() => ); const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList')); + export default function Home({categoryId}) { const bannerRef = useRef(null); const wrapperRef = useRef(null); + const auth = getAuth(); + const handleOnLoad = () => { wrapperRef.current.style.height = 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}) @@ -86,6 +90,8 @@ export default function Home({categoryId}) { loadCategories() }, []) + const [dataCategories, setDataCategories] = useState([]) + return ( <BasicLayout> <Seo @@ -122,15 +128,21 @@ export default function Home({categoryId}) { </div> </div> - <div className='my-16 flex flex-col gap-y-16'> + <div className='my-16 flex flex-col gap-y-8'> <ServiceList /> <div id='flashsale'> <PreferredBrand /> </div> - <FlashSale /> + {!auth?.feature?.soApproval && ( + <> + <ProgramPromotion /> <FlashSale /> + </> + )} <PromotinProgram /> <CategoryPilihan categories={dataCategories}/> <CategoryDynamic/> + <CategoryPilihan categories={dataCategories}/> + <CategoryDynamic/> <CategoryHomeId /> <BannerSection /> <CustomerReviews /> @@ -151,11 +163,22 @@ export default function Home({categoryId}) { <PreferredBrand /> </div> </DelayRender> + {!auth?.feature?.soApproval && ( + <> + <DelayRender renderAfter={400}> + <ProgramPromotion /> + </DelayRender> + <DelayRender renderAfter={600}> + <FlashSale /> + </DelayRender> + </> + )} <DelayRender renderAfter={600}> - <FlashSale /> + <PromotinProgram /> </DelayRender> <DelayRender renderAfter={600}> - <PromotinProgram /> + <CategoryPilihan categories={dataCategories}/> + <CategoryDynamicMobile/> </DelayRender> <DelayRender renderAfter={600}> <CategoryPilihan categories={dataCategories}/> @@ -175,4 +198,4 @@ export default function Home({categoryId}) { </MobileView> </BasicLayout> ); -} +}
\ No newline at end of file |
