From ffc18f479e3eef4c4e2608141238f83ca5fa79f4 Mon Sep 17 00:00:00 2001
From: Miqdad <ahmadmiqdad27@gmail.com>
Date: Sun, 1 Jun 2025 20:11:57 +0700
Subject: <miqdad> fix estimated arrival days start NaN

---
 src/lib/checkout/components/Checkout.jsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'src/lib/checkout/components/Checkout.jsx')

diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 8c80640a..77053d1c 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -566,8 +566,15 @@ const Checkout = () => {
       order_line: JSON.stringify(productOrder),
       delivery_amount: biayaKirim,
       carrier_id: selectedCourierId,
-      estimated_arrival_days_start : parseInt(eta_courier_start) + parseInt(productSla),
-      estimated_arrival_days: parseInt(eta_courier) + parseInt(productSla),
+      // estimated_arrival_days_start : parseInt(eta_courier_start) + parseInt(productSla),
+      // estimated_arrival_days: parseInt(eta_courier) + parseInt(productSla),
+      // If NaN conver to 0 (int)
+      estimated_arrival_days_start: (isNaN(parseInt(eta_courier_start)) ? 0 : parseInt(eta_courier_start)) +
+        (isNaN(parseInt(productSla)) ? 0 : parseInt(productSla)),
+
+      estimated_arrival_days: (isNaN(parseInt(eta_courier)) ? 0 : parseInt(eta_courier)) +
+        (isNaN(parseInt(productSla)) ? 0 : parseInt(productSla)),
+
       delivery_service_type: selectedService?.service_type,
       // New release
       // carrier_id: selectedCarrierId,
-- 
cgit v1.2.3

