From 867bbe11bf98297177d999fa4a8c69054d2ec72d Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 19 Nov 2024 17:29:59 +0700
Subject: <iman> bug shipnent

---
 src/lib/treckingAwb/component/Manifest.jsx | 124 ++++++++++++++++-------------
 1 file changed, 70 insertions(+), 54 deletions(-)

(limited to 'src/lib/treckingAwb/component/Manifest.jsx')

diff --git a/src/lib/treckingAwb/component/Manifest.jsx b/src/lib/treckingAwb/component/Manifest.jsx
index fbc95702..02d0bc7a 100644
--- a/src/lib/treckingAwb/component/Manifest.jsx
+++ b/src/lib/treckingAwb/component/Manifest.jsx
@@ -1,16 +1,16 @@
-import odooApi from '@/core/api/odooApi'
-import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
-import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
-import { getAuth } from '@/core/utils/auth'
-import { useEffect, useState } from 'react'
-import { toast } from 'react-hot-toast'
-import ImageNext from 'next/image'
-import { list } from 'postcss'
+import odooApi from '@/core/api/odooApi';
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup';
+import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner';
+import { getAuth } from '@/core/utils/auth';
+import { useEffect, useState } from 'react';
+import { toast } from 'react-hot-toast';
+import ImageNext from 'next/image';
+import { list } from 'postcss';
 
 const Manifest = ({ idAWB, closePopup }) => {
-  const [manifests, setManifests] = useState(null)
-  const [isLoading, setIsLoading] = useState(false)
-
+  const [manifests, setManifests] = useState(null);
+  const [isLoading, setIsLoading] = useState(false);
+  console.log('manifests', manifests);
   const formatCustomDate = (date) => {
     const months = [
       'Jan',
@@ -24,61 +24,60 @@ const Manifest = ({ idAWB, closePopup }) => {
       'Sep',
       'Oct',
       'Nov',
-      'Dec'
-    ]
+      'Dec',
+    ];
 
-    const parts = date.split(' ') // Pisahkan tanggal dan waktu
-    const [datePart, timePart] = parts
-    const [yyyy, mm, dd] = datePart.split('-')
-    const [hh, min] = timePart.split(':')
+    const parts = date.split(' '); // Pisahkan tanggal dan waktu
+    const [datePart, timePart] = parts;
+    const [yyyy, mm, dd] = datePart.split('-');
+    const [hh, min] = timePart.split(':');
 
-    const monthAbbreviation = months[parseInt(mm, 10) - 1]
+    const monthAbbreviation = months[parseInt(mm, 10) - 1];
 
-    return `${dd} ${monthAbbreviation} ${hh}:${min}`
-  }
+    return `${dd} ${monthAbbreviation} ${hh}:${min}`;
+  };
 
   const getManifest = async () => {
-    setIsLoading(true)
-    const auth = getAuth()
-    let list
-    if(auth){
+    setIsLoading(true);
+    const auth = getAuth();
+    let list;
+    if (auth) {
       list = await odooApi(
         'GET',
         `/api/v1/partner/${auth.partnerId}/stock-picking/${idAWB}/tracking`
-      )
-    }else{
-      list = await odooApi(
-        'GET',
-        `/api/v1/stock-picking/${idAWB}/tracking`
-      )
+      );
+    } else {
+      list = await odooApi('GET', `/api/v1/stock-picking/${idAWB}/tracking`);
     }
-    setManifests(list)
-    setIsLoading(false)
-  }
+    setManifests(list);
+    setIsLoading(false);
+  };
 
   useEffect(() => {
     if (idAWB) {
-      getManifest()
+      getManifest();
     } else {
-      setManifests(null)
+      setManifests(null);
     }
-  }, [idAWB])
+  }, [idAWB]);
 
-  const [copied, setCopied] = useState(false)
+  const [copied, setCopied] = useState(false);
 
   const handleCopyClick = () => {
-    const textToCopy = manifests?.waybillNumber
-    navigator.clipboard.writeText(textToCopy)
-    setCopied(true)
-    toast.success('No Resi Berhasil di Copy')
-    setTimeout(() => setCopied(false), 2000) // Reset copied state after 2 seconds
-  }
+    const textToCopy = manifests?.waybillNumber;
+    navigator.clipboard.writeText(textToCopy);
+    setCopied(true);
+    toast.success('No Resi Berhasil di Copy');
+    setTimeout(() => setCopied(false), 2000); // Reset copied state after 2 seconds
+  };
 
   return (
     <>
       {isLoading && (
         <BottomPopup active={true} close=''>
-          <div className='leading-7 text-gray_r-12/80 flex justify-center'>Mohon Tunggu</div>
+          <div className='leading-7 text-gray_r-12/80 flex justify-center'>
+            Mohon Tunggu
+          </div>
           <div className='container flex justify-center my-4'>
             <LogoSpinner width={48} height={48} />
           </div>
@@ -111,11 +110,14 @@ const Manifest = ({ idAWB, closePopup }) => {
           </div>
           <div className=''>
             <h1 className='text-body-1'>
-              Estimasi tiba pada <span className='text-gray_r-11 text-sm'>({manifests?.eta})</span>
+              Estimasi tiba pada{' '}
+              <span className='text-gray_r-11 text-sm'>({manifests?.eta})</span>
             </h1>
             <h1 className='text-sm mt-2 mb-3'>
               Dikirim Menggunakan{' '}
-              <span className='text-red-500 font-semibold'>{manifests?.deliveryOrder.carrier}</span>
+              <span className='text-red-500 font-semibold'>
+                {manifests?.deliveryOrder.carrier}
+              </span>
             </h1>
             {manifests?.waybillNumber && (
               <div className='flex justify-between items-center'>
@@ -154,10 +156,16 @@ const Manifest = ({ idAWB, closePopup }) => {
                     {manifests.delivered == true && index == 0 ? (
                       <div
                         class={`absolute w-6 h-6 rounded-full mt-1.5 -left-3 border ${
-                          index == 0 ? 'bg-green-100 border-green-100' : 'bg-gray_r-7 border-white'
+                          index == 0
+                            ? 'bg-green-100 border-green-100'
+                            : 'bg-gray_r-7 border-white'
                         }`}
                       >
-                        <ImageNext src='/images/open-box(1).svg' width={30} height={20} />
+                        <ImageNext
+                          src='/images/open-box(1).svg'
+                          width={30}
+                          height={20}
+                        />
                       </div>
                     ) : (
                       <div
@@ -167,7 +175,9 @@ const Manifest = ({ idAWB, closePopup }) => {
                     {manifests.delivered != true && (
                       <div
                         class={`absolute w-3 h-3 rounded-full mt-1.5 -left-1.5 border ${
-                          index == 0 ? 'bg-green-600 border-green-600' : 'bg-gray_r-7 border-white'
+                          index == 0
+                            ? 'bg-green-600 border-green-600'
+                            : 'bg-gray_r-7 border-white'
                         } `}
                       />
                     )}
@@ -176,9 +186,15 @@ const Manifest = ({ idAWB, closePopup }) => {
                       {formatCustomDate(manifest.datetime)}
                     </time>
                     {manifests.delivered == true && index == 0 && (
-                      <p class={`leading-6 font-semibold text-sm text-green-600 `}>Sudah Sampai</p>
+                      <p
+                        class={`leading-6 font-semibold text-sm text-green-600 `}
+                      >
+                        Sudah Sampai
+                      </p>
                     )}
-                    <p class={`leading-6 text-[12px] text-gray_r-11`}>{manifest.description}</p>
+                    <p class={`leading-6 text-[12px] text-gray_r-11`}>
+                      {manifest.description}
+                    </p>
                   </li>
                 </>
               ))}
@@ -187,7 +203,7 @@ const Manifest = ({ idAWB, closePopup }) => {
         </BottomPopup>
       )}
     </>
-  )
-}
+  );
+};
 
-export default Manifest
+export default Manifest;
-- 
cgit v1.2.3

