summaryrefslogtreecommitdiff
path: root/src/pages/index.jsx
blob: 4493fe3192ea2110118d95b7e0f8d165614cba17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import dynamic from 'next/dynamic';
import { useRef } from 'react';

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 { FlashSaleSkeleton } from '@/lib/flashSale/skeleton/FlashSaleSkeleton';
import PreferredBrandSkeleton from '@/lib/home/components/Skeleton/PreferredBrandSkeleton';
import BannerPromoSkeleton from '@/lib/home/components/Skeleton/BannerPromoSkeleton';
import PromotinProgram from '@/lib/promotinProgram/components/HomePage';
import PagePopupIformation from '~/modules/popup-information';
import useProductDetail from '~/modules/product-detail/stores/useProductDetail';
import { getAuth } from '~/libs/auth';

const BasicLayout = dynamic(() =>
  import('@/core/components/layouts/BasicLayout')
);
const HeroBanner = dynamic(() => import('@/components/ui/HeroBanner'), {
  loading: () => <HeroBannerSkeleton />,
});
const HeroBannerSecondary = dynamic(
  () => import('@/components/ui/HeroBannerSecondary'),
  {
    loading: () => <HeroBannerSkeleton />,
  }
);
const PopularProduct = dynamic(() => import('@/components/ui/PopularProduct'), {
  loading: () => <PopularProductSkeleton />,
});

const PreferredBrand = dynamic(
  () => import('@/lib/home/components/PreferredBrand'),
  {
    loading: () => <PreferredBrandSkeleton />,
  }
);

const FlashSale = dynamic(
  () => import('@/lib/flashSale/components/FlashSale'),
  {
    loading: () => <FlashSaleSkeleton />,
  }
);

const ProgramPromotion = dynamic(() =>
  import('@/lib/home/components/PromotionProgram'),
{
  loading: () => <BannerPromoSkeleton />,
}
);

const BannerSection = dynamic(() =>
  import('@/lib/home/components/BannerSection')
);
const CategoryHomeId = dynamic(() =>
  import('@/lib/home/components/CategoryHomeId')
);
const CustomerReviews = dynamic(() =>
  import('@/lib/review/components/CustomerReviews')
);
const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList'));

export default function Home() {
  const bannerRef = useRef(null);
  const wrapperRef = useRef(null);

  const auth = getAuth();

  const handleOnLoad = () => {
    wrapperRef.current.style.height =
      bannerRef.current?.querySelector(':first-child')?.clientHeight + 'px';
  };

  return (
    <BasicLayout>
      <Seo
        title='Indoteknik.com: B2B Industrial Supply & Solution'
        description='Temukan pilihan produk B2B Industri &amp; Alat Teknik untuk Perusahaan, UMKM &amp; Pemerintah dengan lengkap, mudah dan transparan.'
        additionalMetaTags={[
          {
            name: 'keywords',
            content:
              'indoteknik, indoteknik.com, toko teknik, toko perkakas, jual genset, jual fogging, jual krisbow, harga krisbow, harga alat safety, harga pompa air',
          },
        ]}
      />

      <PagePopupIformation />

      <DesktopView>
        <div className='container mx-auto'>
          <div
            className='flex min-h-[400px] h-[460px]'
            ref={wrapperRef}
            onLoad={handleOnLoad}
          >
            <div className='w-2/12'>
              <HeroBannerSecondary />
            </div>
            <div className='w-7/12 px-1' ref={bannerRef}>
              <HeroBanner />
            </div>
            <div className='w-3/12'>
              <DelayRender renderAfter={200}>
                <PopularProduct />
              </DelayRender>
            </div>
          </div>

          <div className='my-16 flex flex-col gap-y-8'>
            <ServiceList />
            <div id='flashsale'>
              <PreferredBrand />
            </div>
            {!auth?.feature?.soApproval && (
              <>
              <DelayRender renderAfter={200}>
                <ProgramPromotion />
              </DelayRender>
              <DelayRender renderAfter={200}>
                <FlashSale />
              </DelayRender>
              </>
            )}
            <PromotinProgram />
            <CategoryHomeId />
            <BannerSection />
            <CustomerReviews />
          </div>
        </div>
      </DesktopView>

      <MobileView>
        <DelayRender renderAfter={200}>
          <HeroBanner />
        </DelayRender>
        <div className='flex flex-col gap-y-12 my-6'>
          <DelayRender renderAfter={400}>
            <ServiceList />
          </DelayRender>
          <DelayRender renderAfter={400}>
            <div id='flashsale'>
              <PreferredBrand />
            </div>
          </DelayRender>
          {!auth?.feature?.soApproval && (
            <>
              <DelayRender renderAfter={400}>
                <ProgramPromotion />
              </DelayRender>
              <DelayRender renderAfter={600}>
                <FlashSale />
              </DelayRender>
            </>
          )}
          <DelayRender renderAfter={600}>
            <PromotinProgram />
          </DelayRender>
          <DelayRender renderAfter={800}>
            <PopularProduct />
          </DelayRender>
          <DelayRender renderAfter={1000}>
            <CategoryHomeId />
            <BannerSection />
          </DelayRender>
          <DelayRender renderAfter={1200}>
            <CustomerReviews />
          </DelayRender>
        </div>
      </MobileView>
    </BasicLayout>
  );
}