From 58601bc17b6f0516eee9c36aa36e39f1dea3ad77 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Wed, 26 Feb 2025 10:47:58 +0700
Subject: bitehsip

---
 src/lib/checkout/components/SectionExpedition.jsx | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

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

diff --git a/src/lib/checkout/components/SectionExpedition.jsx b/src/lib/checkout/components/SectionExpedition.jsx
index a00858e5..b261cae0 100644
--- a/src/lib/checkout/components/SectionExpedition.jsx
+++ b/src/lib/checkout/components/SectionExpedition.jsx
@@ -49,7 +49,7 @@ function reverseMappingCourier(couriersOdoo, couriers, includeInstant = false) {
       shipment_range: item.shipment_duration_range,
       shipment_unit: item.shipment_duration_unit,
       price: item.price,
-      service_type: item.service_type,
+      service_type: courier_service_code,
       description: item.description,
     };
 
@@ -81,13 +81,6 @@ function reverseMappingCourier(couriersOdoo, couriers, includeInstant = false) {
 }
 
 
-function isHiloday(){
-  const today = new Date();
-  const day = today.getDay();
-
-  return day === 6 || day === 7
-}
-
 function mappingCourier(couriersOdoo, couriers, notIncludeInstant = false) {
   const validCourierMap = couriersOdoo.reduce((acc, courier) => {
     acc[courier.label.toLowerCase()] = courier.carrierId;
@@ -144,9 +137,6 @@ function mappingCourier(couriersOdoo, couriers, notIncludeInstant = false) {
   }, {});
 }
 
-function hasCanInstantFalse(items) {
-  return items.some((item) => item.canInstant === false);
-}
 
 // interface CourierService {
 //   courier_name: string;
@@ -181,6 +171,7 @@ export default function SectionExpedition({ products }) {
   const [onFocusSelectedCourier, setOnFocuseSelectedCourier] = useState(false);
   const [couriers, setCouriers] = useState(null);
   const [slaProducts, setSlaProducts] = useState(null);
+  const [addHolidays, setAddHolidays] = useState(0);
 
   const {
     checkWeigth,
@@ -194,7 +185,8 @@ export default function SectionExpedition({ products }) {
     setSelectedService,
     listExpedisi,
     productSla,
-    setProductSla
+    setProductSla,
+    setSelectedCourierId
   } = useCheckout();
 
   let destination = {};
@@ -217,7 +209,6 @@ export default function SectionExpedition({ products }) {
     try {
       const ids = products.map((p) => p.id).join(',')
       const res = await odooApi('GET', `/api/v1/product/variants/sla?ids=${ids}`)
-
       setSlaProducts(res);
     } catch (error) {
       console.error('Failed to fetch expedition rates:', error);
@@ -230,7 +221,7 @@ export default function SectionExpedition({ products }) {
 
   useEffect(() => {
     if (slaProducts) {
-      let productSla = slaProducts?.slaDuration
+      let productSla = slaProducts?.slaTotal
       if(slaProducts.slaUnit === 'jam') {
         productSla = 1
       }
@@ -282,11 +273,13 @@ export default function SectionExpedition({ products }) {
     setIsOpen(false);
     setOnFocuseSelectedCourier(false);
     const courier = code;
+    console.log('ini courier', courier, couriers);
     setSelectedService(null);
     setBiayaKirim(0);
     if (courier !== 0 && courier !== 32) {
       if (courier.courier) {
         setSelectedCourier(courier.courier.courier_code);
+        setSelectedCourierId(courier.carrierId)
         setServiceOptions(Object.values(courier.courier.service_type));
       } else {
         if (
@@ -328,8 +321,6 @@ export default function SectionExpedition({ products }) {
     setIsOpen(false);
   };
 
-  console.log('ini selectedCourier', couriers);
-
   return (
     <form onSubmit={handleSubmit(onSubmit)}>
       <div className='px-4 py-2'>
-- 
cgit v1.2.3

