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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
|
import { useEffect, useRef, useState } from 'react';
import ImageNext from 'next/image';
import { LazyLoadComponent } from 'react-lazy-load-image-component';
import { Box, Skeleton, Tooltip } from '@chakra-ui/react';
import { HeartIcon } from '@heroicons/react/24/outline';
import { Info } from 'lucide-react';
import LazyLoad from 'react-lazy-load';
import { toast } from 'react-hot-toast';
import { useRouter } from 'next/router';
import Image from '@/core/components/elements/Image/Image';
import Link from '@/core/components/elements/Link/Link';
import DesktopView from '@/core/components/views/DesktopView';
import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
import CountDown2 from '@/core/components/elements/CountDown/CountDown2';
import currencyFormat from '@/core/utils/currencyFormat';
import { updateItemCart } from '@/core/utils/cart';
import { createSlug } from '@/core/utils/slug';
import whatsappUrl from '@/core/utils/whatsappUrl';
import { sellingProductFormat } from '@/core/utils/formatValue';
import odooApi from '@/core/api/odooApi';
import useAuth from '@/core/hooks/useAuth';
import { useProductCartContext } from '@/contexts/ProductCartContext';
import PromotionType from '@/lib/promotinProgram/components/PromotionType';
import ProductSimilar from '../ProductSimilar';
import ProductCard from '../ProductCard';
import productSimilarApi from '../../api/productSimilarApi';
import ColumnsSLA from './ColumnsSLA';
import Breadcrumb from './Breadcrumb';
import ProductPromoSection from '~/modules/product-promo/components/Section';
const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
const router = useRouter();
const auth = useAuth();
const { slug } = router.query;
const [quantityActive, setQuantity] = useState(null);
const [lowestPrice, setLowestPrice] = useState(null);
const [product, setProducts] = useState(products);
const [addCartAlert, setAddCartAlert] = useState(false);
const [isLoadingSLA, setIsLoadingSLA] = useState(true);
const [promotionType, setPromotionType] = useState(false);
const [promotionActiveId, setPromotionActiveId] = useState(null);
const [selectVariantPromoActive, setSelectVariantPromoActive] =
useState(null);
const [backgorundFlashSale, setBackgorundFlashSale] = useState(null);
const { setRefreshCart, refreshCart } = useProductCartContext();
useEffect(() => {
setLowestPrice({ price: product?.lowestPrice });
}, [product]);
useEffect(() => {
const getBackgound = async () => {
const get = await odooApi(
'GET',
'/api/v1/banner?type=flash-sale-background-banner'
);
setBackgorundFlashSale(get[0].image);
};
getBackgound();
}, []);
const [informationTab, setInformationTab] = useState(
informationTabOptions[0].value
);
const variantQuantityRefs = useRef([]);
const setVariantQuantityRef = (variantId) => (element) => {
if (element) {
let variantIndex = product.variants.findIndex(
(varian) => varian.id == variantId
);
product.variants[variantIndex].quantity = element?.value;
}
variantQuantityRefs.current[variantId] = element;
};
const validQuantity = (quantity) => {
let isValid = true;
if (!quantity || quantity < 1 || isNaN(parseInt(quantity))) {
toast.error('Jumlah barang minimal 1');
isValid = false;
}
return isValid;
};
const updateCart = (variantId, quantity, source) => {
let dataUpdate = {
productId: variantId,
quantity,
selected: true,
source: source === 'buy' ? 'buy' : null,
};
if (product.variants.length > 1) {
let variantIndex = product.variants.findIndex(
(varian) => varian.id == variantId
);
dataUpdate['programLineId'] =
product.variants[variantIndex].programActive;
} else {
dataUpdate['programLineId'] = promotionActiveId;
}
updateItemCart(dataUpdate);
};
const redirectToLogin = (action, variantId, quantity) => {
const nextURL = `/shop/product/${slug}?action=${action}&variantId=${variantId}&qty=${quantity}`;
router.push(`/login?next=${encodeURIComponent(nextURL)}`);
return true;
};
const handleAddToCart = (variantId) => {
const quantity = variantQuantityRefs.current[variantId].value;
if (!validQuantity(quantity)) return;
if (!auth) {
return redirectToLogin('add_to_cart', variantId, quantity);
}
let source = 'cart';
updateCart(variantId, quantity, source);
setRefreshCart(true);
setAddCartAlert(true);
};
const handleQuantityChange = (variantId) => (event) => {
const { value } = event.target;
const variantIndex = product.variants.findIndex(
(variant) => variant.id === variantId
);
if (variantIndex !== -1) {
product.variants[variantIndex].quantity = parseInt(value, 10); // Pastikan untuk mengubah ke tipe number jika diperlukan
// Lakukan sesuatu jika nilai quantity diubah
}
};
const handleBuy = (variant) => {
const quantity = variantQuantityRefs.current[variant].value;
if (!validQuantity(quantity)) return;
if (!auth) {
return redirectToLogin('buy', variant, quantity);
}
let source = 'buy';
updateCart(variant, quantity, source);
router.push(`/shop/checkout?source=buy`);
};
const variantSectionRef = useRef(null);
const goToVariantSection = () => {
if (variantSectionRef.current) {
const position = variantSectionRef.current.getBoundingClientRect();
window.scrollTo({
top: position.top - 120 + window.pageYOffset,
behavior: 'smooth',
});
}
};
const handlePromoClick = (variantId) => {
setSelectVariantPromoActive(variantId);
setPromotionType(true);
};
const productSimilarQuery = [
product?.name,
`fq=-product_id_i:${product.id}`,
`fq=-manufacture_id_i:${product.manufacture?.id || 0}`,
].join('&');
const [productSimilarInBrand, setProductSimilarInBrand] = useState(null);
useEffect(() => {
const loadProductSimilarInBrand = async () => {
const productSimilarQuery = [
product?.name,
`fq=-product_id_i:${product.id}`,
].join('&');
const source = 'right';
const dataProductSimilar = await productSimilarApi({
query: productSimilarQuery,
source,
});
setProductSimilarInBrand(dataProductSimilar.products);
};
if (!productSimilarInBrand) loadProductSimilarInBrand();
}, [product, productSimilarInBrand]);
useEffect(() => {
const fetchData = async () => {
const promises = product.variants.map(async (variant) => {
const dataSLA = await odooApi(
'GET',
`/api/v1/product_variant/${variant.id}/stock`
);
return {
...variant,
sla: dataSLA,
};
});
const variantData = await Promise.all(promises);
product.variants = variantData;
setIsLoadingSLA(false);
};
if (product.variantTotal == 1) fetchData();
}, [product]);
return (
<DesktopView>
<div className='container mx-auto pt-10'>
<Breadcrumb productId={product.id} productName={product.name} />
<div className='w-full flex flex-wrap'>
<div className='w-3/12'>
<div className='relative mb-2'>
{product?.flashSale?.remainingTime > 0 &&
lowestPrice?.price.discountPercentage > 0 && (
<div className={`absolute bottom-0 w-full`}>
<div className='absolute bottom-0 w-full h-full'>
<ImageNext
src={
backgorundFlashSale ||
'/images/BG-FLASH-SALE.jpg'
}
width={1000}
height={100}
className='h-full'
/>
</div>
<div className='relative'>
<div className='flex gap-x-2 items-center p-2'>
<div className='bg-yellow-400 rounded-full p-1 h-9 w-20 flex items-center justify-center '>
<span className='text-lg font-bold'>
{Math.floor(product.lowestPrice.discountPercentage)}
%
</span>
</div>
<div
className={`bg-red-600 border border-solid border-yellow-400 rounded-full h-9 p-2 flex w-[50%] items-center justify-center gap-x-1`}
>
<ImageNext
src='/images/ICON_FLASH_SALE_WEBSITE_INDOTEKNIK.svg'
alt='Flash Sale'
width={17}
height={10}
/>
<span className='text-white text-sm font-semibold'>
{product?.flashSale?.tag != 'false' ||
product?.flashSale?.tag
? product?.flashSale?.tag
: 'FLASH SALE'}
</span>
</div>
<div>
<CountDown2
initialTime={product.flashSale.remainingTime}
/>
</div>
</div>
</div>
</div>
)}
<Image
src={product.image}
alt={product.name}
className='h-[430px] object-contain object-center w-full border border-gray_r-4'
/>
</div>
<div>
<p className='text-justify text-xs leading-5'>
<span className='font-semibold '>Keterangan : </span>Gambar atau
foto berperan sebagai ilustrasi produk. Kadang tidak sesuai
dengan kondisi terbaru dengan berbagai perubahan dan perbaikan.
Hubungi tim sales kami untuk informasi yang lebih baik perihal
gambar di 021-2933 8828.
</p>
</div>
</div>
<div className='w-6/12 px-6'>
<h1 className='text-title-md leading-10 font-medium'>
{product?.name}
</h1>
<div className='mt-10'>
<div className='flex p-3'>
<div className='w-4/12 text-gray_r-12/70'>Nomor SKU</div>
<div className='w-8/12'>SKU-{product.id}</div>
</div>
<div className='flex p-3 bg-gray_r-4'>
<div className='w-4/12 text-gray_r-12/70'>Part Number</div>
<div className='w-8/12'>{product.code || '-'}</div>
</div>
<div className='flex p-3'>
<div className='w-4/12 text-gray_r-12/70'>Manufacture</div>
<div className='w-8/12'>
{product.manufacture?.name ? (
<Link
href={createSlug(
'/shop/brands/',
product.manufacture?.name,
product.manufacture?.id
)}
>
{product.manufacture?.name}
</Link>
) : (
<div>-</div>
)}
</div>
</div>
<div className='flex p-3 items-center bg-gray_r-4'>
<div className='w-4/12 text-gray_r-12/70'>Persiapan Barang</div>
<div className='w-8/12'>
{product.variants.length > 1 && (
<button
type='button'
onClick={goToVariantSection}
className={`flex gap-x-1 items-center p-2 rounded-lg w-auto btn-light`}
>
<span className='text-red-600 text-sm'>
Lihat Selengkapnya
</span>
</button>
)}
{product.variants.length === 1 && (
<>
{!product.variants[0]?.sla && (
<Skeleton width='20%' height='16px' />
)}
{product.variants[0]?.sla && (
<Tooltip
placement='top'
label={`Masa Persiapan Barang ${product.variants[0]?.sla?.slaDate}`}
>
<Box className='w-fit flex items-center gap-x-2'>
{product.variants[0]?.sla?.slaDate}
<Info size={16} />
</Box>
</Tooltip>
)}
</>
)}
</div>
</div>
{product.variants.length === 1 && (
<div className='flex p-3 '>
<div className='w-4/12 text-gray_r-12/70'>Stock</div>
<div className='w-8/12'>
{!product.variants[0]?.sla && (
<Skeleton width='10%' height='16px' />
)}
{product?.variants[0].sla?.qty > 0 && (
<span>{product?.variants[0].sla?.qty}</span>
)}
{product?.variants[0].sla?.qty == 0 && (
<a
href={whatsappUrl('product', {
name: product.name,
manufacture: product?.manufacture?.name,
url: createSlug(
'/shop/product/',
product.name,
product.id,
true
),
})}
className='text-danger-500 font-medium'
>
Tanya Admin
</a>
)}
</div>
</div>
)}
<div
className={`flex p-3 ${
product.variants.length > 1 ? '' : 'bg-gray_r-4'
} `}
>
<div className='w-4/12 text-gray_r-12/70'>Berat Barang</div>
<div className='w-8/12'>
{product?.weight > 0 && <span>{product?.weight} KG</span>}
{product?.weight == 0 && (
<a
href={whatsappUrl('productWeight', {
name: product.name,
url: createSlug(
'/shop/product/',
product.name,
product.id,
true
),
})}
className='text-danger-500 font-medium'
>
Tanya Berat
</a>
)}
</div>
</div>
{product.variants.length <= 1 && (
<div className='pt-3'>
<div className='flex mt-1'>
<PromotionType
variantId={product.variants[0].id}
setPromotionActiveId={setPromotionActiveId}
promotionActiveId={promotionActiveId}
quantity={quantityActive}
product={product}
></PromotionType>
<ProductPromoSection productId={product.variants[0].id} />
</div>
</div>
)}
</div>
</div>
<div className='w-3/12'>
{product.variants.length > 1 &&
product.lowestPrice.priceDiscount > 0 && (
<div className='text-gray_r-12/80'>Harga mulai dari: </div>
)}
{/* {lowestPrice?.discountPercentage > 0 && (
<div className='flex gap-x-1 items-center mt-2'>
<div className='badge-solid-red text-caption-1'>
{lowestPrice?.discountPercentage}%
</div>
<div className='text-gray_r-9 text-caption-1'>
Include PPN {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)}
</div>
{product.flashSale.remainingTime > 0 && (
<div className='bg-red-600 rounded-full mb-1 p-2 pl-3 pr-3 flex w-fit items-center gap-x-1'>
<ImageNext
src='/images/ICON_FLASH_SALE_WEBSITE_INDOTEKNIK.svg'
width={15}
height={10}
/>
<span className='text-white text-xs font-semibold'>
{product?.flashSale?.tag != 'false' || product?.flashSale?.tag
? product?.flashSale?.tag
: 'FLASH SALE'}
</span>
</div>
)}
</div>
)} */}
{product?.qtySold > 0 && (
<div className='text-gray_r-9'>
{sellingProductFormat(product?.qtySold) + ' Terjual'}
</div>
)}
{product?.flashSale?.id &&
lowestPrice?.price.discountPercentage > 0 ? (
<>
<div className='flex gap-x-1 items-center mt-2'>
<div className='badge-solid-red text-caption-1'>
{Math.floor(lowestPrice?.price?.discountPercentage)}%
</div>
<div className='text-gray_r-9 line-through text-caption-1'>
{currencyFormat(lowestPrice?.price?.price)}
</div>
<div className='text-danger-500 font-semibold text-xl'>
{currencyFormat(lowestPrice?.price?.priceDiscount)}
</div>
</div>
<div className='text-gray_r-9 text-base font-normal mt-1'>
Termasuk PPN:{' '}
{currencyFormat(
lowestPrice?.price.priceDiscount *
process.env.NEXT_PUBLIC_PPN
)}
</div>
</>
) : (
<h3 className='text-danger-500 font-semibold mt-1 text-title-md'>
{lowestPrice?.price.price > 0 ? (
<>
{currencyFormat(lowestPrice?.price.price)}
<div className='text-gray_r-9 text-base font-normal mt-1'>
Termasuk PPN:{' '}
{currencyFormat(
lowestPrice?.price.price * process.env.NEXT_PUBLIC_PPN
)}
</div>
</>
) : (
<span className='text-gray_r-12/90 font-normal text-h-sm'>
Hubungi kami untuk dapatkan harga terbaik,
<a
href={whatsappUrl('product', {
name: product.name,
manufacture: product.manufacture?.name,
url: createSlug(
'/shop/product/',
product.name,
product.id,
true
),
})}
className='text-danger-500 underline'
rel='noopener noreferrer'
target='_blank'
>
klik disini
</a>
</span>
)}
</h3>
)}
{product.variants.length > 1 ? (
<button
type='button'
onClick={goToVariantSection}
className='btn-solid-red w-full mt-6'
>
Lihat Varian
</button>
) : (
<div className='flex gap-x-3 mt-4'>
<input
type='number'
className='form-input w-16 py-2 text-center bg-gray_r-1'
ref={setVariantQuantityRef(product.variants[0].id)}
onChange={handleQuantityChange(product.variants[0].id)}
defaultValue={1}
/>
<button
type='button'
onClick={() => handleAddToCart(product.variants[0].id)}
className='flex-1 py-2 btn-yellow'
>
Keranjang
</button>
<button
type='button'
onClick={() => handleBuy(product.variants[0].id)}
className='flex-1 py-2 btn-solid-red'
>
Beli
</button>
</div>
)}
<div className='flex mt-4'>
<button
className='flex items-center gap-x-1'
onClick={toggleWishlist}
>
{wishlist.data?.productTotal > 0 ? (
<HeartIcon className='w-6 fill-danger-500 text-danger-500' />
) : (
<HeartIcon className='w-6' />
)}
Wishlist
</button>
</div>
<div className='border border-gray_r-6 overflow-auto mt-4'>
<div className='font-medium text-center p-4 bg-gray_r-1 border-b border-gray_r-6 sticky top-0 z-10'>
Produk Serupa
</div>
<div className='h-full divide-y divide-gray_r-6 max-h-[550px]'>
{productSimilarInBrand &&
productSimilarInBrand?.map((product) => (
<div className='py-2' key={product.id}>
<ProductCard product={product} variant='horizontal' />
</div>
))}
</div>
</div>
</div>
</div>
<div className='w-full'>
<div className='mt-12'>
<div className='text-h-lg font-semibold'>Informasi Produk</div>
<div className='flex gap-x-4 mt-6 mb-4'>
{informationTabOptions.map((option) => (
<TabButton
value={option.value}
key={option.value}
active={informationTab == option.value}
onClick={() => setInformationTab(option.value)}
>
{option.label}
</TabButton>
))}
</div>
<div className='flex'>
<div className='w-3/4 leading-8 product__description'>
<TabContent active={informationTab == 'description'}>
<span
dangerouslySetInnerHTML={{
__html:
product.description != ''
? product.description
: 'Belum ada deskripsi produk.',
}}
/>
</TabContent>
<TabContent active={informationTab == 'information'}>
Belum ada informasi.
</TabContent>
</div>
</div>
</div>
</div>
{product.variants.length > 1 && (
<div className='mt-12' ref={variantSectionRef}>
<div className='text-h-lg font-semibold mb-6'>Varian Produk</div>
<div className='table-specification'>
<table>
<thead>
<tr>
<th>Part Number</th>
<th>Varian</th>
<th>Stock</th>
<th>Persiapan Barang</th>
<th>Harga</th>
<th>Jumlah</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{product.variants.map((variant, index) => (
<tr key={variant.id}>
<td className='flex items-center justify-center gap-x-1'>
{variant.isFlashsale && (
<span className='blink-color-flash-sale'>
🗲
</span>
)}
{variant.code}
</td>
<td>{variant.attributes.join(', ') || '-'}</td>
<LazyLoadComponent>
<ColumnsSLA variant={variant} product={product} />
</LazyLoadComponent>
<td>
{variant.isFlashsale &&
variant?.price?.discountPercentage > 0 ? (
<>
<div className='flex items-center gap-x-1 justify-center'>
<div className='badge-solid-red text-caption-1'>
{Math.floor(variant?.price?.discountPercentage)}
%
</div>
<div className='line-through text-caption-1 text-gray_r-11'>
{currencyFormat(variant?.price?.price)}
</div>{' '}
<div className=' text-caption-1 text-red-600 font-semibold'>
{currencyFormat(variant?.price?.priceDiscount)}
</div>{' '}
</div>
<div className=' text-caption-1 text-gray_r-11 mb-1'>
Inc. PPN:{' '}
{currencyFormat(
variant.price.priceDiscount *
process.env.NEXT_PUBLIC_PPN
)}
</div>
</>
) : (
<div>
{variant?.price?.price > 0 ? (
<>
<div className=' text-caption-1 text-red-600 font-semibold'>
{currencyFormat(variant?.price?.price)}
</div>{' '}
<div className=' text-caption-1 text-gray_r-11 mb-1'>
Inc. PPN:{' '}
{currencyFormat(
variant?.price?.price *
process.env.NEXT_PUBLIC_PPN
)}
</div>
</>
) : (
<a
href={whatsappUrl('product', {
name: variant.name,
manufacture: product.manufacture?.name,
url: createSlug(
'/shop/product/',
product.name,
product.id,
true
),
})}
className='text-red_r-11'
rel='noopener noreferrer'
target='_blank'
>
Call for Inquiry
</a>
)}
</div>
)}
{/* {variant.price.discountPercentage > 0 &&
variant.price.priceDiscount > 0 && (
<>
<div className='line-through text-caption-1 text-gray_r-11 mb-1'>
{currencyFormat(variant.price.price)}
</div>{' '}
</>
)} */}
{/* <VariantPrice id={variant.id} /> */}
</td>
<td>
<input
type='number'
className='form-input w-16 py-2 text-center bg-gray_r-1'
ref={setVariantQuantityRef(variant.id)}
onChange={handleQuantityChange(variant.id)}
defaultValue={1}
/>
</td>
<td className='flex gap-x-3'>
{/* {variant.programActive ? (
<ImageNext
src='/images/noun-applied-check2.svg'
alt=''
height={60}
width={60}
onClick={() => handlePromoClick(variant.id)}
className='cursor-pointer'
></ImageNext>
) : (
variant.hasProgram ? ( <div className='w-[60px] flex justify-center'>
<ImageNext
src='/images/noun-discount-5796402.svg'
alt=''
height={30}
width={30}
onClick={() => handlePromoClick(variant.id)}
className='cursor-pointer'
></ImageNext>
</div>):( <div className='w-[60px] flex justify-center'>
<ImageNext
src='/images/noun-discount-57964023.svg'
alt=''
height={30}
width={30}
className='cursor-pointer'
></ImageNext>
</div>)
)} */}
<button
type='button'
onClick={() => handleAddToCart(variant.id)}
className='flex-1 py-2 btn-yellow'
>
Keranjang
</button>
<button
type='button'
onClick={() => handleBuy(variant.id)}
className='flex-1 py-2 btn-solid-red'
>
Beli
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
<div className='my-12'>
<div className='text-h-lg font-semibold mb-6'>
Kamu Mungkin Juga Suka
</div>
<LazyLoad>
<ProductSimilar query={productSimilarQuery} />
</LazyLoad>
</div>
<BottomPopup
className=' !h-[75%]'
title='Pakai Promo'
active={promotionType}
close={() => setPromotionType(false)}
>
<div className='flex mt-4'>
<PromotionType
isModal={true}
variantId={selectVariantPromoActive}
setPromotionActiveId={setPromotionActiveId}
promotionActiveId={promotionActiveId}
quantity={quantityActive}
product={product}
setProducts={setProducts}
></PromotionType>
</div>
</BottomPopup>
<BottomPopup
className='!container'
title='Berhasil Ditambahkan'
active={addCartAlert}
close={() => setAddCartAlert(false)}
>
<div className='flex mt-4'>
<div className='w-[10%]'>
<Image
src={product.image}
alt={product.name}
className='h-32 object-contain object-center w-full border border-gray_r-4'
/>
</div>
<div className='ml-3 flex flex-1 items-center font-normal'>
{product.name}
</div>
<div className='ml-3 flex items-center font-normal'>
<Link
href='/shop/cart'
className='flex-1 py-2 text-gray_r-12 btn-yellow'
>
Lihat Keranjang
</Link>
</div>
</div>
<div className='mt-8 mb-4'>
<div className='text-h-sm font-semibold mb-6'>
Kamu Mungkin Juga Suka
</div>
<LazyLoad>
<ProductSimilar query={productSimilarQuery} />
</LazyLoad>
</div>
</BottomPopup>
</div>
</DesktopView>
);
};
const informationTabOptions = [
{ value: 'description', label: 'Deskripsi' },
{ value: 'information', label: 'Info Penting' },
];
const TabButton = ({ children, active, ...props }) => {
const activeClassName = active
? 'text-danger-500 underline underline-offset-4'
: 'text-gray_r-12/80';
return (
<button
{...props}
type='button'
className={`font-medium ${activeClassName}`}
>
{children}
</button>
);
};
const TabContent = ({ children, active, className = '', ...props }) => (
<div {...props} className={`${active ? 'block' : 'hidden'} ${className}`}>
{children}
</div>
);
export default ProductDesktop;
|