From f4eba44dbacf13be894744e48d4248714daee223 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 17 Jul 2024 15:22:34 +0700 Subject: update nomor wa di keranjang --- src/lib/checkout/components/Checkout.jsx | 4 +++- src/lib/checkout/components/CheckoutOld.jsx | 4 +++- src/lib/checkout/components/CheckoutSection.jsx | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 77c3590b..3d7d47b1 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -1589,7 +1589,9 @@ const PickupAddress = ({ label }) => ( Kodepos : 14440

Telp : 021-2933 8828/29

-

Mobile : 0813 9000 7430

+

+ Mobile : 0817-1718-1922 +

); diff --git a/src/lib/checkout/components/CheckoutOld.jsx b/src/lib/checkout/components/CheckoutOld.jsx index e2c45ce6..3c4229aa 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

Telp : 021-2933 8828/29

-

Mobile : 0813 9000 7430

+

+ Mobile : 0817-1718-1922 +

) diff --git a/src/lib/checkout/components/CheckoutSection.jsx b/src/lib/checkout/components/CheckoutSection.jsx index affe6138..3ed4b115 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

Telp : 021-2933 8828/29

-

Mobile : 0813 9000 7430

+

+ Mobile : 0817-1718-1922 +

); -- cgit v1.2.3 From d0f97021c611d07944f3cbc7e2610b1d495d897f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 17 Jul 2024 15:41:02 +0700 Subject: update hover wa link --- src/lib/checkout/components/Checkout.jsx | 2 +- src/lib/checkout/components/CheckoutOld.jsx | 2 +- src/lib/checkout/components/CheckoutSection.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 3d7d47b1..92e14db6 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -1589,7 +1589,7 @@ const PickupAddress = ({ label }) => ( Kodepos : 14440

Telp : 021-2933 8828/29

-

+

Mobile : 0817-1718-1922

diff --git a/src/lib/checkout/components/CheckoutOld.jsx b/src/lib/checkout/components/CheckoutOld.jsx index 3c4229aa..5b479a73 100644 --- a/src/lib/checkout/components/CheckoutOld.jsx +++ b/src/lib/checkout/components/CheckoutOld.jsx @@ -802,7 +802,7 @@ const PickupAddress = ({ label }) => ( Daerah Khusus Ibukota Jakarta, Indonesia Kodepos : 14440

Telp : 021-2933 8828/29

-

+

Mobile : 0817-1718-1922

diff --git a/src/lib/checkout/components/CheckoutSection.jsx b/src/lib/checkout/components/CheckoutSection.jsx index 3ed4b115..623152c6 100644 --- a/src/lib/checkout/components/CheckoutSection.jsx +++ b/src/lib/checkout/components/CheckoutSection.jsx @@ -186,7 +186,7 @@ export const PickupAddress = ({ label }) => ( Kodepos : 14440

Telp : 021-2933 8828/29

-

+

Mobile : 0817-1718-1922

-- cgit v1.2.3 From ecaa66653e57e369b97674ff239177244f8f83ff Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 22 Jul 2024 11:13:59 +0700 Subject: voucher in product card --- src/lib/product/components/ProductCard.jsx | 152 +++++++++++++++++------------ 1 file changed, 92 insertions(+), 60 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 98732407..818dbbcf 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -14,7 +14,15 @@ import useUtmSource from '~/hooks/useUtmSource'; const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const router = useRouter(); const utmSource = useUtmSource(); + const [discount, setDiscount] = useState(0); + let voucherPastiHemat = 0; + + if (product?.voucherPastiHemat.length > 0) { + const stringVoucher = product?.voucherPastiHemat[0]; + const validJsonString = stringVoucher.replace(/'/g, '"'); + voucherPastiHemat = JSON.parse(validJsonString); + } const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, @@ -38,42 +46,59 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { ), }; + const hitungDiscountVoucher = () => { + let countDiscount = 0; + if (voucherPastiHemat.discount_type === 'percentage') { + countDiscount = product?.lowestPrice.priceDiscount * (voucherPastiHemat.discount_amount / 100); + if (voucherPastiHemat.max_discount > 0 && countDiscount > voucherPastiHemat.max_discount) { + countDiscount = voucherPastiHemat.max_discount; + } + } else { + countDiscount = voucherPastiHemat.discount_amount; + } + + setDiscount(countDiscount); + }; + + useEffect(() => { + hitungDiscountVoucher(); + }, []); + if (variant == 'vertical') { return ( -
+
-
- {product?.name} -
-
- {product?.isSni && ( - - )} -
-
- {product?.isTkdn && ( - - )} +
+ {product?.name} +
+
+ {product?.isSni && ( + + )} +
+
+ {product?.isTkdn && ( + + )} +
-
- {router.pathname != '/' && product?.flashSale?.id > 0 && (
@@ -178,6 +203,13 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )}
)} + {discount > 0 && ( +
+
+ Hemat : {currencyFormat(discount)} +
+
+ )}
{product?.stockTotal > 0 && ( @@ -200,37 +232,37 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
-
- {product?.name} -
-
- {product?.isSni && ( - - )} -
-
- {product?.isTkdn && ( - - )} +
+ {product?.name} +
+
+ {product?.isSni && ( + + )} +
+
+ {product?.isTkdn && ( + + )} +
-
{product.variantTotal > 1 && (
{product.variantTotal} Varian -- cgit v1.2.3 From 0433d92034937c76135ceb83ef88402464006866 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 22 Jul 2024 15:08:07 +0700 Subject: get new voucher --- src/lib/checkout/api/getVoucher.js | 10 ++++++++++ src/lib/checkout/components/Checkout.jsx | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/api/getVoucher.js b/src/lib/checkout/api/getVoucher.js index 07cf376e..15c6abbb 100644 --- a/src/lib/checkout/api/getVoucher.js +++ b/src/lib/checkout/api/getVoucher.js @@ -1,4 +1,5 @@ import odooApi from '@/core/api/odooApi' +import { getAuth } from '@/core/utils/auth' export const getVoucher = async (id, source) => { let dataVoucher = null @@ -19,3 +20,12 @@ export const findVoucher = async (code, id, source) => { } return dataVoucher } + + +export const getVoucherNew = async (source) => { + const id = getAuth()?.id; + const dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?${source}`) + + return dataVoucher + +} \ No newline at end of file diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 92e14db6..61410bdf 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); @@ -119,7 +120,8 @@ const Checkout = () => { const voucher = async () => { if (!listVouchers) { try { - let dataVoucher = await getVoucher(auth?.id, query); + let source = 'source=' + query; + let dataVoucher = await getVoucherNew(source); SetListVoucher(dataVoucher); } finally { setLoadingVoucher(false); @@ -127,14 +129,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) { @@ -166,6 +170,8 @@ const Checkout = () => { }, [bottomPopup]); useEffect(() => { + + // voucher() const loadExpedisi = async () => { let dataExpedisi = await ExpedisiList(); dataExpedisi = dataExpedisi.map((expedisi) => ({ @@ -176,6 +182,10 @@ const Checkout = () => { setExpedisi(dataExpedisi); }; loadExpedisi(); + if(qVoucher === 'PASTIHEMAT'){ + let code = qVoucher; + handleUseVoucher(code, !isChecked); + } const handlePopState = () => { router.push('/shop/cart'); @@ -186,7 +196,7 @@ const Checkout = () => { return () => { window.onpopstate = null; }; - // voucher() + }, []); const hitungDiscountVoucher = (code) => { @@ -407,13 +417,13 @@ 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); } }; -- cgit v1.2.3 From 95081416190d09bbbe4f3d745e69ff81258bde7a Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 22 Jul 2024 15:38:48 +0700 Subject: add params voucher --- src/lib/checkout/components/Checkout.jsx | 40 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'src/lib') 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) => { @@ -231,14 +225,22 @@ const Checkout = () => { SetDiscountVoucher(countDiscount); }, [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

Telp : 021-2933 8828/29

-

+

+ Mobile : 0817-1718-1922 -

+ +

); -- cgit v1.2.3 From 6be3ec5948932671013aba249fbc5c44ecf9e95b Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 25 Jul 2024 13:51:46 +0700 Subject: feedback review --- src/lib/product/components/ProductCard.jsx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 818dbbcf..283a10c6 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -49,8 +49,13 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const hitungDiscountVoucher = () => { let countDiscount = 0; if (voucherPastiHemat.discount_type === 'percentage') { - countDiscount = product?.lowestPrice.priceDiscount * (voucherPastiHemat.discount_amount / 100); - if (voucherPastiHemat.max_discount > 0 && countDiscount > voucherPastiHemat.max_discount) { + countDiscount = + product?.lowestPrice.priceDiscount * + (voucherPastiHemat.discount_amount / 100); + if ( + voucherPastiHemat.max_discount > 0 && + countDiscount > voucherPastiHemat.max_discount + ) { countDiscount = voucherPastiHemat.max_discount; } } else { @@ -203,10 +208,10 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )}
)} - {discount > 0 && ( + {discount > 0 && product?.flashSale?.id < 1 && (
- Hemat : {currencyFormat(discount)} + Voucher : {currencyFormat(discount)}
)} @@ -351,6 +356,14 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
)} + {discount > 0 && product?.flashSale?.id < 1 && ( +
+
+ Voucher : {currencyFormat(discount)} +
+
+ )} +
{product?.stockTotal > 0 && (
Ready Stock
-- cgit v1.2.3 From 2b2600ca31fb5aaacf7a70e0ea90b26c553af061 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 1 Aug 2024 15:34:59 +0700 Subject: fixing height card --- src/lib/product/components/ProductCard.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 283a10c6..e10241a7 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -71,7 +71,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { if (variant == 'vertical') { return ( -
+