From e39d3b0082e83ad08044918f0b6d8e977223100d Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001"
Date: Mon, 17 Jul 2023 16:30:17 +0700
Subject: feedback UAT
---
src/lib/checkout/components/Checkout.jsx | 73 +++++++++++++++++++++++---------
1 file changed, 53 insertions(+), 20 deletions(-)
(limited to 'src/lib/checkout')
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 098d1e66..0c7a35fa 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -91,6 +91,9 @@ const Checkout = () => {
const [findCodeVoucher, SetFindVoucher] = useState(null)
const [selisihHargaCode, SetSelisihHargaCode] = useState(null)
const [buttonTerapkan, SetButtonTerapkan] = useState(false)
+ const [checkoutValidation, setCheckoutValidation] = useState(false)
+
+ const expedisiValidation = useRef(null)
const voucher = async () => {
let dataVoucher = await getVoucher()
@@ -212,6 +215,7 @@ const Checkout = () => {
}, [products])
useEffect(() => {
+ setCheckoutValidation(false)
const loadServiceRajaOngkir = async () => {
const body = {
origin: 2127,
@@ -261,7 +265,7 @@ const Checkout = () => {
useEffect(() => {
if (selectedExpedisi) {
let serviceType = selectedExpedisi.split(',')
- if(serviceType[0] === 0){
+ if (serviceType[0] === 0) {
setSelectedExpedisi(0)
}
setselectedCarrier(serviceType[0])
@@ -281,6 +285,21 @@ const Checkout = () => {
toast.error('Maksimal ukuran file adalah 5MB', { position: 'bottom-center' })
return
}
+ if (selectedExpedisi === 0) {
+ setCheckoutValidation(true)
+ if (expedisiValidation.current) {
+ const position = expedisiValidation.current.getBoundingClientRect()
+ window.scrollTo({
+ top: position.top - 300 + window.pageYOffset,
+ behavior: 'smooth'
+ })
+ }
+ return
+ }
+ if (selectedCarrier != 1 && biayaKirim == 0) {
+ toast.error('Maaf, layanan tidak tersedia. Mohon pilih expedisi lain.')
+ return
+ }
setIsLoading(true)
const productOrder = products.map((product) => ({
product_id: product.id,
@@ -337,6 +356,7 @@ const Checkout = () => {
if (isCheck) {
if (code === activeVoucher) {
SetActiveVoucher(null)
+ SetDiscountVoucher(0)
} else {
SetActiveVoucher(code)
SetFindVoucher(null)
@@ -414,7 +434,8 @@ const Checkout = () => {
{findCodeVoucher === 2 && (
- Tambah {selisihHargaCode} untuk pakai promo ini
+ Tambah {selisihHargaCode} untuk pakai promo
+ ini
)}
@@ -471,9 +492,7 @@ const Checkout = () => {
{activeVoucher === item.code && (
-
- Voucher digunakan{' '}
-
+ Voucher digunakan
)}
@@ -556,6 +575,8 @@ const Checkout = () => {
listExpedisi={listExpedisi}
setSelectedExpedisi={setSelectedExpedisi}
checkWeigth={checkWeigth}
+ checkoutValidation={checkoutValidation}
+ expedisiValidation={expedisiValidation}
/>
{
@@ -738,6 +757,8 @@ const Checkout = () => {
listExpedisi={listExpedisi}
setSelectedExpedisi={setSelectedExpedisi}
checkWeigth={checkWeigth}
+ checkoutValidation={checkoutValidation}
+ expedisiValidation={expedisiValidation}
/>
{
@@ -1028,13 +1042,24 @@ const SectionValidation = ({ address }) =>
)
-const SectionExpedisi = ({ address, listExpedisi, setSelectedExpedisi, checkWeigth }) =>
+const SectionExpedisi = ({
+ address,
+ listExpedisi,
+ setSelectedExpedisi,
+ checkWeigth,
+ checkoutValidation,
+ expedisiValidation
+}) =>
address?.rajaongkirCityId > 0 && (
-
+
Pilih Expedisi :
-
-
{checkWeigth == true && (
--
cgit v1.2.3