From adc316e70faf20ea375b3e590998a36997b6b6e2 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Wed, 26 Nov 2025 14:56:36 +0700 Subject: balikin --- src/pages/index.jsx | 248 +++++++++++++++++++++++----------------------------- 1 file changed, 110 insertions(+), 138 deletions(-) (limited to 'src/pages') diff --git a/src/pages/index.jsx b/src/pages/index.jsx index fd960e8a..ba8c44af 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,6 +1,7 @@ import { HeroBannerSkeleton } from '@/components/skeleton/BannerSkeleton'; import { PopularProductSkeleton } from '@/components/skeleton/PopularProductSkeleton'; import Seo from '@/core/components/Seo'; +import DelayRender from '@/core/components/elements/DelayRender/DelayRender'; import DesktopView from '@/core/components/views/DesktopView'; import MobileView from '@/core/components/views/MobileView'; import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBrandSkeleton'; @@ -9,118 +10,77 @@ import dynamic from 'next/dynamic'; import { useRef } from 'react'; import { getAuth } from '~/libs/auth'; import MediaNews from '../lib/home/components/MediaNews'; -import { popularProductApi, popularProductApiSSR } from '@/api/productApi'; -/* ============================ - * DYNAMIC IMPORT SETTINGS - * ============================ */ - -// Layout const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout') ); -// Popup -const PagePopupIformation = dynamic( - () => import('~/modules/popup-information'), - { ssr: false } -); - -// CATEGORY (SSR TRUE) -const CategoryPilihan = dynamic( - () => import('../lib/home/components/CategoryPilihan'), - { ssr: true } +const PagePopupIformation = dynamic(() => + import('~/modules/popup-information'), { + ssr: false + } ); -const CategoryDynamic = dynamic( - () => import('@/lib/home/components/CategoryDynamic'), - { ssr: true } +const CategoryPilihan = dynamic(() => + import('../lib/home/components/CategoryPilihan') ); - -const CategoryDynamicMobile = dynamic( - () => import('@/lib/home/components/CategoryDynamicMobile'), - { ssr: true } -); - -const CategoryHomeId = dynamic( - () => import('@/lib/home/components/CategoryHomeId'), - { ssr: true } -); - -// PRODUCT (SSR TRUE) -const PopularProduct = dynamic( - () => import('@/components/ui/PopularProduct'), - { loading: () => , ssr: true } +const HeroBanner = dynamic(() => import('@/components/ui/HeroBanner'), { + loading: () => , +}); +const HeroBannerSecondary = dynamic( + () => import('@/components/ui/HeroBannerSecondary'), + { + loading: () => , + } ); +const PopularProduct = dynamic(() => import('@/components/ui/PopularProduct'), { + loading: () => , +}); const PreferredBrand = dynamic( () => import('@/lib/home/components/PreferredBrand'), - { loading: () => , ssr: true } + { + loading: () => , + } ); const FlashSale = dynamic( () => import('@/lib/flashSale/components/FlashSale'), - { ssr: true } ); const ProgramPromotion = dynamic( - () => import('@/lib/home/components/PromotionProgram'), - { ssr: true } + () => import('@/lib/home/components/PromotionProgram') ); -// CSR ONLY COMPONENTS -const HeroBanner = dynamic( - () => import('@/components/ui/HeroBanner'), - { loading: () => , ssr: false } +const BannerSection = dynamic(() => + import('@/lib/home/components/BannerSection') +); +const CategoryHomeId = dynamic( + () => import('@/lib/home/components/CategoryHomeId') ); -const HeroBannerSecondary = dynamic( - () => import('@/components/ui/HeroBannerSecondary'), - { loading: () => , ssr: false } +const CategoryDynamic = dynamic(() => + import('@/lib/home/components/CategoryDynamic') ); -const BannerSection = dynamic( - () => import('@/lib/home/components/BannerSection'), - { ssr: false } +const CategoryDynamicMobile = dynamic(() => + import('@/lib/home/components/CategoryDynamicMobile') ); const CustomerReviews = dynamic( () => import('@/lib/review/components/CustomerReviews'), { ssr: false } -); - -const ServiceList = dynamic( - () => import('@/lib/home/components/ServiceList'), - { ssr: false } -); - - -/* ===================================== - * SERVER SIDE PROPS (HARUS DI LUAR) - * ===================================== */ +); // need to ssr:false +const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList'), { + ssr: false, +}); // need to ssr: false - export async function getServerSideProps(context) { - const auth = getAuth(context.req); - - const popularProducts = await popularProductApiSSR(); - - return { - props: { - auth, - popularProducts - } - }; - } - - -/* ============================ - * MAIN PAGE COMPONENT - * ============================ */ - -export default function Home({ auth, popularProducts }) { +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'; @@ -130,109 +90,121 @@ export default function Home({ auth, popularProducts }) { <> - {/* DESKTOP */} - -
+
-
+
- -
+
- -
- +
+ + +
-
+
- -
+
- {!auth?.feature?.soApproval && ( <> - - + + + + + + )} - + {/* */} -
- - {/* MOBILE */} - - -
- - - -
- -
- + + + +
+ + + + + +
+ +
+
{!auth?.feature?.soApproval && ( <> - - + + + + + + )} - - - - - - - - - - + + {/* */} + + + + + + + + + + + + + + +
-- cgit v1.2.3