diff options
Diffstat (limited to 'src/lib/checkout/components')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 61410bdf..9bc0257e 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -129,7 +129,7 @@ const Checkout = () => { } }; const VoucherCode = async (code) => { - const source = 'code=' + code+'&source='+query; + const source = 'code=' + code + '&source=' + query; // let dataVoucher = await findVoucher(code, auth.id, query); let dataVoucher = await getVoucherNew(source); if (dataVoucher.length <= 0) { @@ -170,8 +170,7 @@ const Checkout = () => { }, [bottomPopup]); useEffect(() => { - - // voucher() + voucher(); const loadExpedisi = async () => { let dataExpedisi = await ExpedisiList(); dataExpedisi = dataExpedisi.map((expedisi) => ({ @@ -182,10 +181,6 @@ const Checkout = () => { setExpedisi(dataExpedisi); }; loadExpedisi(); - if(qVoucher === 'PASTIHEMAT'){ - let code = qVoucher; - handleUseVoucher(code, !isChecked); - } const handlePopState = () => { router.push('/shop/cart'); @@ -196,7 +191,6 @@ const Checkout = () => { return () => { window.onpopstate = null; }; - }, []); const hitungDiscountVoucher = (code) => { @@ -232,13 +226,21 @@ const Checkout = () => { }, [activeVoucher, listVouchers]); useEffect(() => { + if (qVoucher === 'PASTIHEMAT' && listVouchers) { + let code = qVoucher; + VoucherCode(code); + } + }, [listVouchers]); + + useEffect(() => { setProducts(cartCheckout?.products); setCheckWeight(cartCheckout?.hasProductWithoutWeight); setTotalWeight(cartCheckout?.totalWeight.g); - const hasFlashSale = cartCheckout?.products.some(product => product.hasFlashsale); + const hasFlashSale = cartCheckout?.products.some( + (product) => product.hasFlashsale + ); setHasFlashSale(hasFlashSale); }, [cartCheckout]); - useEffect(() => { setCheckoutValidation(false); @@ -357,7 +359,7 @@ const Checkout = () => { carrier_id: selectedCarrierId, estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, - flash_sale : hasFlashSale, // dibuat negasi untuk ngetest kebalikan nilai false + flash_sale: hasFlashSale, // dibuat negasi untuk ngetest kebalikan nilai false voucher: activeVoucher, type: 'sale_order', }; @@ -373,7 +375,7 @@ const Checkout = () => { toast.error('Gagal melakukan transaksi, terjadi kesalahan internal'); return; } - + gtagPurchase(products, biayaKirim, isCheckouted.name); const midtrans = async () => { @@ -417,13 +419,17 @@ const Checkout = () => { } else { SetActiveVoucher(code); SetFindVoucher(null); - document.getElementById('uniqCode') ? document.getElementById('uniqCode').value = '' : ''; + document.getElementById('uniqCode') + ? (document.getElementById('uniqCode').value = '') + : ''; SetButtonTerapkan(false); } } else { SetActiveVoucher(code); SetFindVoucher(null); - document.getElementById('uniqCode') ? document.getElementById('uniqCode').value = '' : ''; + document.getElementById('uniqCode') + ? (document.getElementById('uniqCode').value = '') + : ''; SetButtonTerapkan(false); } }; @@ -1599,9 +1605,11 @@ const PickupAddress = ({ label }) => ( Kodepos : 14440 </p> <p className='mt-1 text-gray_r-11'>Telp : 021-2933 8828/29</p> - <p className='mt-1 text-gray_r-11 hover:text-red-500'><a href={whatsappUrl()} target='_blank' rel='noreferrer'> + <p className='mt-1 text-gray_r-11 hover:text-red-500'> + <a href={whatsappUrl()} target='_blank' rel='noreferrer'> Mobile : 0817-1718-1922 - </a></p> + </a> + </p> </div> </div> ); |
