From 0dab223d410e1c6011bfb4e1e850dfe566c8d044 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 29 Aug 2023 14:11:23 +0700
Subject: add params etd di checkout

---
 src/lib/checkout/components/Checkout.jsx | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

(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 afb94c10..0eb05345 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -297,10 +297,12 @@ const Checkout = () => {
       order_line: JSON.stringify(productOrder),
       delivery_amount: biayaKirim,
       carrier_id: selectedCarrierId,
+      estimated_arrival_days: splitDuration(etd),
       delivery_service_type: selectedExpedisiService,
       voucher: activeVoucher,
       type: 'sale_order'
     }
+
     if (query) {
       data.source = 'buy'
     }
@@ -1444,6 +1446,22 @@ function calculateEstimatedArrival(duration) {
   return ''
 }
 
+function splitDuration(duration){
+  if (duration) {
+    let estimationDate = null
+    if (duration.includes('-')){
+      estimationDate = duration.split('-')
+      estimationDate = parseInt(estimationDate[1])
+    }else{
+      estimationDate = parseInt(duration)
+    }
+
+    return estimationDate
+  }
+
+  return ''
+}
+
 const extractDuration = (text) => {
   const matches = text.match(/\d+(?:-\d+)?/g)
 
-- 
cgit v1.2.3

