summaryrefslogtreecommitdiff
path: root/src/pages/index.jsx
blob: ba8c44affa147306901ebdee082d30ee7570f8b3 (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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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';
import PagePopupInformation from '@/lib/home/components/PopupBannerPromotion';
import dynamic from 'next/dynamic';
import { useRef } from 'react';
import { getAuth } from '~/libs/auth';
import MediaNews from '../lib/home/components/MediaNews';

const BasicLayout = dynamic(() =>
  import('@/core/components/layouts/BasicLayout')
);

const PagePopupIformation = dynamic(() =>
  import('~/modules/popup-information'), {
    ssr: false
  }
);

const CategoryPilihan = dynamic(() =>
  import('../lib/home/components/CategoryPilihan')
);
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'),
);

const ProgramPromotion = dynamic(
  () => import('@/lib/home/components/PromotionProgram')
);

const BannerSection = dynamic(() =>
  import('@/lib/home/components/BannerSection')
);
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'),
  { ssr: false }
); // need to ssr:false
const ServiceList = dynamic(() => import('@/lib/home/components/ServiceList'), {
  ssr: false,
}); // need to ssr: false

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';
  };

  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',
            },
          ]}
          openGraph={
            {
              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.',
              images: [
                {
                  url: 'https://indoteknik.com/icon.jpg',
                  width: 800,
                  height: 600,
                  alt: 'indoteknik.com',
                },
              ],
            }
          }
        />

        <PagePopupIformation />

        <DesktopView>
          <PagePopupInformation />
          <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 />
              <MediaNews />
              <div id='flashsale'>
                <PreferredBrand />
              </div>
              {!auth?.feature?.soApproval && (
                <>
                  <DelayRender renderAfter={200}>
                    <ProgramPromotion />
                  </DelayRender>
                  <DelayRender renderAfter={200}>
                    <FlashSale />
                  </DelayRender>
                </>
              )}
              {/* <PromotinProgram /> */}
              <CategoryPilihan />
              <CategoryDynamic />
              <CategoryHomeId />
              <BannerSection />
              <CustomerReviews />
            </div>
          </div>
        </DesktopView>
        <MobileView>
          <PagePopupInformation />
          <DelayRender renderAfter={200}>
            <HeroBanner />
          </DelayRender>
          <div className='flex flex-col gap-y-4 my-6'>
            <DelayRender renderAfter={400}>
              <ServiceList />
              <MediaNews />
            </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={600}>
              <CategoryPilihan />
              <CategoryDynamicMobile />
            </DelayRender>
            <DelayRender renderAfter={800}>
              <PopularProduct />
            </DelayRender>
            <DelayRender renderAfter={1000}>
              <CategoryHomeId />
              <BannerSection />
            </DelayRender>
            <DelayRender renderAfter={1200}>
              <CustomerReviews />
            </DelayRender>
          </div>
        </MobileView>
      </BasicLayout>
    </>
  );
}