diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 34 | ||||
| -rw-r--r-- | src/lib/checkout/components/SectionExpedition.jsx | 1 |
2 files changed, 25 insertions, 10 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 668c7ac0..aad3d66d 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -374,13 +374,17 @@ const Checkout = () => { } return; } - if (!selectedService) { - toast.error('Harap pilih tipe layanan pengiriman'); - return; - } - if (selectedCourier != 1 && biayaKirim == 0) { - toast.error('Maaf, layanan tidak tersedia. Mohon pilih expedisi lain.'); - return; + if (selectedCourierId !== SELF_PICKUP_ID) { // Menggunakan selectedCourierId karena lebih spesifik dan numerik + if (!selectedService) { // Jika kurir bukan Self Pickup, maka harus ada layanan yang dipilih + toast.error('Harap pilih tipe layanan pengiriman'); + return; + } + // Validasi biaya kirim hanya untuk kurir selain Self Pickup (dan ID kurir 1 jika itu kasus khusus) + // Jika selectedCourierId adalah 1 (misalnya kurir internal yang bisa gratis), lewati validasi biayaKirim 0 + if (selectedCourierId !== 1 && biayaKirim === 0) { + toast.error('Maaf, layanan tidak tersedia untuk ekspedisi ini. Mohon pilih ekspedisi lain atau layanan lain.'); + return; + } } setIsLoading(true); const productOrder = products.map((product) => ({ @@ -388,9 +392,19 @@ const Checkout = () => { quantity: product.quantity, available_quantity: product?.availableQuantity, })); - let estimated_courier = etd.split('-').map(Number); - let eta_courier = Math.max(...estimated_courier); - let eta_courier_start = Math.min(...estimated_courier); + + let eta_courier = 0; + let eta_courier_start = 0; + + if (selectedCourierId !== SELF_PICKUP_ID && etd) { + const estimated_courier = etd.split('-').map(Number); + eta_courier = Math.max(...estimated_courier); + eta_courier_start = Math.min(...estimated_courier); + } + + // let estimated_courier = etd.split('-').map(Number); + // let eta_courier = Math.max(...estimated_courier); + // let eta_courier_start = Math.min(...estimated_courier); let data = { // partner_shipping_id: auth.partnerId,, diff --git a/src/lib/checkout/components/SectionExpedition.jsx b/src/lib/checkout/components/SectionExpedition.jsx index 40084048..fdad04ce 100644 --- a/src/lib/checkout/components/SectionExpedition.jsx +++ b/src/lib/checkout/components/SectionExpedition.jsx @@ -308,6 +308,7 @@ export default function SectionExpedition({ products }) { } } else { setSelectedCourier(courier === 32 ? 'SELF PICKUP' : null); + setSelectedCourierId(courier); setServiceOptions([]); } }; |
