From 78d02a2392924d5d4a21206fb52f627251883af8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 6 Mar 2023 11:59:03 +0700 Subject: fix --- src/lib/auth/components/Activate.jsx | 2 +- src/lib/auth/components/Login.jsx | 2 +- src/lib/auth/components/Register.jsx | 2 +- src/lib/checkout/components/Checkout.jsx | 49 ++++- src/lib/checkout/components/FinishCheckout.jsx | 11 - src/lib/checkout/email/FinishCheckoutEmail.jsx | 281 +++++++++++++++---------- src/lib/variant/components/VariantCard.jsx | 3 - 7 files changed, 220 insertions(+), 130 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/Activate.jsx b/src/lib/auth/components/Activate.jsx index f67cc168..8fdc1096 100644 --- a/src/lib/auth/components/Activate.jsx +++ b/src/lib/auth/components/Activate.jsx @@ -117,7 +117,7 @@ const Activate = () => { } return ( -
+
{ } return ( -
+
{ } return ( -
+
{ const router = useRouter() @@ -56,6 +57,7 @@ const Checkout = () => { }) }, [addresses]) + const [paymentMethod, setPaymentMethod] = useState('') const [products, setProducts] = useState(null) const [totalAmount, setTotalAmount] = useState(0) const [totalDiscountAmount, setTotalDiscountAmount] = useState(0) @@ -96,6 +98,11 @@ const Checkout = () => { const [isLoading, setIsLoading] = useState(false) const checkout = async () => { + if (!paymentMethod) { + toast.error('Metode pembayaran harus dipilih', { position: 'bottom-center' }) + return + } + const file = poFile.current.files[0] if (typeof file !== 'undefined' && file.size > 5000000) { toast.error('Maksimal ukuran file adalah 5MB', { position: 'bottom-center' }) @@ -121,12 +128,16 @@ const Checkout = () => { toast.error('Gagal melakukan transaksi, terjadi kesalahan internal') return } - - const payment = await axios.post( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/midtrans-payment?transactionId=${isCheckouted.id}` - ) + for (const product of products) deleteItemCart({ productId: product.id }) - window.location.href = payment.data.redirectUrl + if (paymentMethod == 'midtrans') { + const payment = await axios.post( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/midtrans-payment?transactionId=${isCheckouted.id}` + ) + window.location.href = payment.data.redirectUrl + } else { + router.push(`/shop/checkout/finish?order_id=${isCheckouted.name}`) + } } return ( @@ -221,6 +232,34 @@ const Checkout = () => { +
+
Metode Pembayaran
+
+
setPaymentMethod('manual')} + > + Bank BCA (PT. Indoteknik Dotcom) +
8870-4000-81
+
+
setPaymentMethod('midtrans')} + > + Midtrans Payment +
+
+
+ + +
Purchase Order
diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx index f5346d67..33c0d46a 100644 --- a/src/lib/checkout/components/FinishCheckout.jsx +++ b/src/lib/checkout/components/FinishCheckout.jsx @@ -1,17 +1,6 @@ import Link from '@/core/components/elements/Link/Link' -import axios from 'axios' -import { useEffect } from 'react' const FinishCheckout = ({ query }) => { - useEffect(() => { - if (query?.order_id) { - console.log(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderName=${query.order_id}`); - axios.post( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderId=${query.order_id}` - ) - } - }, [query]) - return (
diff --git a/src/lib/checkout/email/FinishCheckoutEmail.jsx b/src/lib/checkout/email/FinishCheckoutEmail.jsx index 950fe318..1a4940ee 100644 --- a/src/lib/checkout/email/FinishCheckoutEmail.jsx +++ b/src/lib/checkout/email/FinishCheckoutEmail.jsx @@ -33,6 +33,7 @@ const FinishCheckoutEmail = ({ transaction, payment, statusPayment }) => { {statusPayment == 'success' && 'Terimakasih untuk pembelian anda!'} {statusPayment == 'pending' && 'Menunggu Pembayaran'} {statusPayment == 'failed' && 'Pembayaran Tidak Berhasil'} + {statusPayment == 'manual' && 'Pembelian di Indoteknik.com'} Hai {transaction.address.customer.name}, @@ -63,6 +64,12 @@ const FinishCheckoutEmail = ({ transaction, payment, statusPayment }) => { kembali dengan produk yang anda inginkan di website Indoteknik.com. )} + {statusPayment == 'manual' && ( + <> + Terima kasih telah mempercayai Indoteknik.com sebagai Platform B2B industrial Supply + & Solution + + )} {['pending', 'failed'].includes(statusPayment) && ( @@ -77,127 +84,185 @@ const FinishCheckoutEmail = ({ transaction, payment, statusPayment }) => { sudah berhasil anda lakukan melalui Whatsapp kami. )} + {statusPayment == 'manual' && ( + <> + Kami mohon kepada {transaction.address.customer.name} untuk dapat segera + menyelesaikan transaksi dengan detail dibawah ini: +
    +
  • Nomor Pembelian: {transaction.name}
  • +
  • Nominal: {transaction.amountTotal}
  • +
  • Tanggal: {transaction.dateOrder}
  • +
+ + )}
- - Detail Transaksi - + {['pending', 'failed', 'success'].includes(statusPayment) && ( + <> + + Detail Transaksi + -
+
-
- {statusPayment == 'success' && - 'Struk ini dapat anda simpan sebagai bukti tambahan dalam transaksi yang telah dilakukan.'} - {statusPayment == 'pending' && - 'Kami akan menginformasikan melalui email setelah anda berhasil melakukan pembayaran.'} - {statusPayment == 'failed' && - 'Dimohon untuk tidak melakukan pembayaran. Karena transaksi anda tidak berhasil dibuat.'} -
+
+ {statusPayment == 'success' && + 'Struk ini dapat anda simpan sebagai bukti tambahan dalam transaksi yang telah dilakukan.'} + {statusPayment == 'pending' && + 'Kami akan menginformasikan melalui email setelah anda berhasil melakukan pembayaran.'} + {statusPayment == 'failed' && + 'Dimohon untuk tidak melakukan pembayaran. Karena transaksi anda tidak berhasil dibuat.'} +
- - No Transaksi (SO) - {transaction.name} - - - Tanggal Transaksi - {payment.transactionTime} - - - Status Pembayaran - - {statusPayment == 'success' && ( -
Berhasil
- )} - {statusPayment == 'pending' && ( -
Pending
- )} - {statusPayment == 'failed' && ( -
Tidak Berhasil
- )} -
-
- - Metode Pembayaran - - {toTitleCase(payment.paymentType.replaceAll('_', ' '))} - - - - Batas Akhir Pembayaran - {payment.expiryTime} - - - Nominal Transfer - - {currencyFormat(payment.grossAmount)} - - + + No Transaksi (SO) + {transaction.name} + + + Tanggal Transaksi + {payment.transactionTime} + + + Status Pembayaran + + {statusPayment == 'success' && ( +
Berhasil
+ )} + {statusPayment == 'pending' && ( +
Pending
+ )} + {statusPayment == 'failed' && ( +
Tidak Berhasil
+ )} +
+
+ + Metode Pembayaran + + {toTitleCase(payment.paymentType.replaceAll('_', ' '))} + + + + Batas Akhir Pembayaran + {payment.expiryTime} + + + Nominal Transfer + + {currencyFormat(payment.grossAmount)} + + - - Detail Produk - + + Detail Produk + -
+
- {transaction.products.map((product) => ( - - - - - - {product.name} - {product.code} -
- - {currencyFormat(product.price.priceDiscount)} - - {product.price.discountPercentage > 0 && ( - <> -   - {currencyFormat(product.price.price)} - - )} -   x {product.quantity} barang -
-
-
- ))} + {transaction.products.map((product) => ( + + + + + + {product.name} + {product.code} +
+ + {currencyFormat(product.price.priceDiscount)} + + {product.price.discountPercentage > 0 && ( + <> +   + + {currencyFormat(product.price.price)} + + + )} +   x {product.quantity} barang +
+
+
+ ))} -
+
- - Subtotal - {currencyFormat(transaction.subtotal)} - - - Total Diskon - - {currencyFormat(transaction.discountTotal)} - - - - PPN 11% (Incl.) - - {currencyFormat(transaction.subtotal * 0.11)} - - + + Subtotal + + {currencyFormat(transaction.subtotal)} + + + + Total Diskon + + {currencyFormat(transaction.discountTotal)} + + + + PPN 11% (Incl.) + + {currencyFormat(transaction.subtotal * 0.11)} + + -
+
+ + + Grand Total + + + {currencyFormat(transaction.amountTotal)} + + + - - Grand Total - - {currencyFormat(transaction.amountTotal)} - - +
+ + )} -
+ {statusPayment == 'manual' && ( + <> + + Dengan cara dibawah ini: +
    +
  • + Lakukan pembayaran manual via mobile app perbankan{' '} + {transaction.address.customer.name} Bank Central Asia (BCA) 8870400081 A/N: + INDOTEKNIK DOTCOM GEMILANG PT +
  • +
  • + Setelah berhasil melakukan pembayaran, mohon agar melakukan Screen Capture bukti + bayar sebagai bukti untuk kami bahwa {transaction.address.customer.name} telah + melakukan transaksi pembayaran +
  • +
  • + Kirimkan bukti transaksi pembayaran anda dengan melakukan reply / balas email + ini dengan melampirkan bukti di attachment / lampiran +
  • +
  • + Transaksi {transaction.address.customer.name} akan segera diproses oleh salah + satu Account Representative Indoteknik +
  • +
+
+ + Jika ada pertanyaan seputar teknis pembayaran {transaction.address.customer.name}{' '} + dapat hubungi kami melalui Email{' '} + (sales@indoteknik.com) atau Whatsapp{' '} + (+62 812-8080-622). + + + Terima kasih atas perhatiannya, selamat kembali beraktifitas + + + )} Best regards, diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx index 6e7ea871..8161473d 100644 --- a/src/lib/variant/components/VariantCard.jsx +++ b/src/lib/variant/components/VariantCard.jsx @@ -47,9 +47,6 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { {product.price.discountPercentage}% )} -

- {currencyFormat(product.price.priceDiscount)} -

{currencyFormat(product.price.priceDiscount)} × {product.quantity} Barang -- cgit v1.2.3