diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-02 09:35:16 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-02 09:35:16 +0700 |
| commit | 40ae7e966913e085abb6644e5be56ee6bd6855fc (patch) | |
| tree | 9abd22773a17d1998e28e0ca0dff1ef128f0b627 /src/lib/checkout/components | |
| parent | 2376bb4ab8f791ce6b99e70478f792b525d4d5fe (diff) | |
| parent | 12c7841770052aefceda899db52b3e6b6d0b5e92 (diff) | |
<iman> Merge branch 'release' into Feature/all-promotion
Diffstat (limited to 'src/lib/checkout/components')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 40 | ||||
| -rw-r--r-- | src/lib/checkout/components/CheckoutOld.jsx | 4 | ||||
| -rw-r--r-- | src/lib/checkout/components/CheckoutSection.jsx | 5 |
3 files changed, 37 insertions, 12 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 081ad9a4..09a791ee 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -30,7 +30,7 @@ import whatsappUrl from '@/core/utils/whatsappUrl'; import addressesApi from '@/lib/address/api/addressesApi'; import CartItem from '~/modules/cart/components/Item.tsx'; import ExpedisiList from '../api/ExpedisiList'; -import { findVoucher, getVoucher } from '../api/getVoucher'; +import { findVoucher, getVoucher, getVoucherNew } from '../api/getVoucher'; const SELF_PICKUP_ID = 32; @@ -40,6 +40,7 @@ const { getProductsCheckout } = require('../api/checkoutApi'); const Checkout = () => { const router = useRouter(); const query = router.query.source ?? null; + const qVoucher = router.query.voucher ?? null; const auth = useAuth(); const [activeVoucher, SetActiveVoucher] = useState(null); @@ -145,14 +146,16 @@ const Checkout = () => { }; const VoucherCode = async (code) => { - let dataVoucher = await findVoucher(code, auth.id, query); + const source = 'code=' + code + '&source=' + query; + // let dataVoucher = await findVoucher(code, auth.id, query); + let dataVoucher = await getVoucherNew(source); if (dataVoucher.length <= 0) { SetFindVoucher(1); return; } let addNewLine = dataVoucher[0]; - let checkList = listVouchers.findIndex( + let checkList = listVouchers?.findIndex( (voucher) => voucher.code == addNewLine.code ); if (checkList >= 0) { @@ -184,6 +187,7 @@ const Checkout = () => { }, [bottomPopup]); useEffect(() => { + voucher(); const loadExpedisi = async () => { let dataExpedisi = await ExpedisiList(); dataExpedisi = dataExpedisi.map((expedisi) => ({ @@ -204,7 +208,6 @@ const Checkout = () => { return () => { window.onpopstate = null; }; - // voucher() }, []); const hitungDiscountVoucher = (code) => { @@ -240,10 +243,19 @@ 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]); @@ -364,7 +376,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, voucher_shipping: activeVoucherShipping, type: 'sale_order', @@ -381,7 +393,7 @@ const Checkout = () => { toast.error('Gagal melakukan transaksi, terjadi kesalahan internal'); return; } - + gtagPurchase(products, biayaKirim, isCheckouted.name); const midtrans = async () => { @@ -425,13 +437,17 @@ const Checkout = () => { } else { SetActiveVoucher(code); SetFindVoucher(null); - document.getElementById('uniqCode').value = ''; + document.getElementById('uniqCode') + ? (document.getElementById('uniqCode').value = '') + : ''; SetButtonTerapkan(false); } } else { SetActiveVoucher(code); SetFindVoucher(null); - document.getElementById('uniqCode').value = ''; + document.getElementById('uniqCode') + ? (document.getElementById('uniqCode').value = '') + : ''; SetButtonTerapkan(false); } }; @@ -1750,7 +1766,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'>Mobile : 0813 9000 7430</p> + <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> </div> </div> ); diff --git a/src/lib/checkout/components/CheckoutOld.jsx b/src/lib/checkout/components/CheckoutOld.jsx index e2c45ce6..5b479a73 100644 --- a/src/lib/checkout/components/CheckoutOld.jsx +++ b/src/lib/checkout/components/CheckoutOld.jsx @@ -802,7 +802,9 @@ const PickupAddress = ({ label }) => ( Daerah Khusus Ibukota Jakarta, Indonesia 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'>Mobile : 0813 9000 7430</p> + <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> </div> </div> ) diff --git a/src/lib/checkout/components/CheckoutSection.jsx b/src/lib/checkout/components/CheckoutSection.jsx index affe6138..623152c6 100644 --- a/src/lib/checkout/components/CheckoutSection.jsx +++ b/src/lib/checkout/components/CheckoutSection.jsx @@ -2,6 +2,7 @@ import Link from 'next/link'; import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; import { AnimatePresence, motion } from 'framer-motion'; import { Divider, Spinner } from '@chakra-ui/react'; +import whatsappUrl from '@/core/utils/whatsappUrl'; export const SectionAddress = ({ address, label, url }) => { return ( @@ -185,7 +186,9 @@ export 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'>Mobile : 0813 9000 7430</p> + <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> </div> </div> ); |
