From 0cf4e527dd7565261349d9485a82695379427892 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 26 Sep 2024 10:06:58 +0700
Subject: <iman> bug ga bisa pilih alamat di quotation

---
 src/lib/quotation/components/Quotation.jsx | 107 +++++++++++++++--------------
 1 file changed, 57 insertions(+), 50 deletions(-)

(limited to 'src/lib/quotation/components/Quotation.jsx')

diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx
index 0ad042de..cf0ad41f 100644
--- a/src/lib/quotation/components/Quotation.jsx
+++ b/src/lib/quotation/components/Quotation.jsx
@@ -39,12 +39,12 @@ const { getProductsCheckout } = require('@/lib/checkout/api/checkoutApi');
 const Quotation = () => {
   const router = useRouter();
   const auth = useAuth();
-  
+
   const { data: cartCheckout } = useQuery('cartCheckout', () =>
     getProductsCheckout()
-);
+  );
 
-const {  setRefreshCart } = useProductCartContext();
+  const { setRefreshCart } = useProductCartContext();
   const SELF_PICKUP_ID = 32;
 
   const [products, setProducts] = useState(null);
@@ -69,18 +69,18 @@ const {  setRefreshCart } = useProductCartContext();
   const [selectedExpedisiService, setselectedExpedisiService] = useState(null);
   const [etd, setEtd] = useState(null);
   const [etdFix, setEtdFix] = useState(null);
-  
+
   const [isApproval, setIsApproval] = useState(false);
-  
+
   const expedisiValidation = useRef(null);
-  
+
   const [selectedAddress, setSelectedAddress] = useState({
     shipping: null,
     invoicing: null,
   });
-  
+
   const [addresses, setAddresses] = useState(null);
-  
+
   const [note_websiteText, setselectedNote_websiteText] = useState('');
 
   useEffect(() => {
@@ -99,6 +99,9 @@ const {  setRefreshCart } = useProductCartContext();
     if (!addresses) return;
 
     const matchAddress = (key) => {
+      if (key === 'invoicing') {
+        key = 'invoice';
+      }
       const addressToMatch = getItemAddress(key);
       const foundAddress = addresses.filter(
         (address) => address.id == addressToMatch
@@ -271,7 +274,7 @@ const {  setRefreshCart } = useProductCartContext();
       toast.error('Maaf, Note wajib dimasukkan.');
       return;
     }
-    
+
     setIsLoading(true);
     const productOrder = products.map((product) => ({
       product_id: product.id,
@@ -286,11 +289,10 @@ const {  setRefreshCart } = useProductCartContext();
       carrier_id: selectedCarrierId,
       estimated_arrival_days: splitDuration(etd),
       delivery_service_type: selectedExpedisiService,
-      note_website : note_websiteText,
+      note_website: note_websiteText,
     };
-    
+
     const isSuccess = await checkoutApi({ data });
-    ;
     setIsLoading(false);
     if (isSuccess?.id) {
       for (const product of products) deleteItemCart({ productId: product.id });
@@ -298,7 +300,7 @@ const {  setRefreshCart } = useProductCartContext();
       setRefreshCart(true);
       return;
     }
-    
+
     toast.error('Gagal melakukan transaksi, terjadi kesalahan internal');
   };
 
@@ -455,25 +457,26 @@ const {  setRefreshCart } = useProductCartContext();
             </Link>{' '}
             yang berlaku
           </p>
-            <hr className='my-4 border-gray_r-6' />
-             
-                  <div className='flex gap-x-2 justify-start mb-4'>
-                    <div className=''>Note</div>
-                      {isApproval && (
-                        <div className='text-caption-1 text-red-500 items-center flex'>*harus diisi</div>
-                      )}
-                    </div>
-                    <div className='text-caption-2 text-gray_r-11'>
-                      <textarea
-                        rows="4"
-                        cols="50"
-                        className={`w-full p-1 rounded border  border-gray_r-6`}
-                        onChange={(e) => setselectedNote_websiteText(e.target.value)}
-                      />
-                  </div>
+          <hr className='my-4 border-gray_r-6' />
+
+          <div className='flex gap-x-2 justify-start mb-4'>
+            <div className=''>Note</div>
+            {isApproval && (
+              <div className='text-caption-1 text-red-500 items-center flex'>
+                *harus diisi
+              </div>
+            )}
+          </div>
+          <div className='text-caption-2 text-gray_r-11'>
+            <textarea
+              rows='4'
+              cols='50'
+              className={`w-full p-1 rounded border  border-gray_r-6`}
+              onChange={(e) => setselectedNote_websiteText(e.target.value)}
+            />
+          </div>
         </div>
-      
-            
+
         <Divider />
 
         <div className='flex gap-x-3 p-4'>
@@ -606,27 +609,31 @@ const {  setRefreshCart } = useProductCartContext();
                 yang berlaku
               </p>
 
-                <div>
-                  <hr className='my-4 border-gray_r-6' />
-
-                  <div className='flex gap-x-1 flex-col mb-4'>
-                    <div className='flex flex-row gap-x-1'>
-                      <div className=''>Note</div>
-                      {isApproval && (
-                        <div className='text-caption-1 text-red-500 items-center flex'>*harus diisi</div>
-                      )}
-                    </div>
-                    <div className='text-caption-2 text-gray_r-11'>
-                      <textarea
-                        rows="4"
-                        cols="50"
-                        className={`w-full p-1 rounded border  border-gray_r-6`}
-                        onChange={(e) => setselectedNote_websiteText(e.target.value)}
-                      />
-                    </div>
+              <div>
+                <hr className='my-4 border-gray_r-6' />
+
+                <div className='flex gap-x-1 flex-col mb-4'>
+                  <div className='flex flex-row gap-x-1'>
+                    <div className=''>Note</div>
+                    {isApproval && (
+                      <div className='text-caption-1 text-red-500 items-center flex'>
+                        *harus diisi
+                      </div>
+                    )}
+                  </div>
+                  <div className='text-caption-2 text-gray_r-11'>
+                    <textarea
+                      rows='4'
+                      cols='50'
+                      className={`w-full p-1 rounded border  border-gray_r-6`}
+                      onChange={(e) =>
+                        setselectedNote_websiteText(e.target.value)
+                      }
+                    />
                   </div>
                 </div>
-        
+              </div>
+
               <hr className='my-4 border-gray_r-6' />
 
               <button
-- 
cgit v1.2.3

