diff options
Diffstat (limited to 'src/lib/treckingAwb')
| -rw-r--r-- | src/lib/treckingAwb/component/Manifest.jsx | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/lib/treckingAwb/component/Manifest.jsx b/src/lib/treckingAwb/component/Manifest.jsx index e2251e3e..acb86f57 100644 --- a/src/lib/treckingAwb/component/Manifest.jsx +++ b/src/lib/treckingAwb/component/Manifest.jsx @@ -7,6 +7,7 @@ import { toast } from 'react-hot-toast'; import ImageNext from 'next/image'; import { list } from 'postcss'; import InformationSection from './InformationSection'; +import Link from 'next/link'; function capitalizeFirstLetter(str) { return str.charAt(0).toUpperCase() + str.slice(1); @@ -19,6 +20,19 @@ function capitalizeWords(str) { .join(' '); } +function mappingLiveTracking(kurir, resi){ + let url = null + switch (kurir){ + case('grab'): + url = 'https://express.grab.com/track/orders?ids='+resi + break; + default: + url = false + } + + return url +} + const Manifest = ({ idAWB, closePopup }) => { const [manifests, setManifests] = useState(null); const [isLoading, setIsLoading] = useState(false); @@ -63,7 +77,7 @@ const Manifest = ({ idAWB, closePopup }) => { setManifests(list); setIsLoading(false); }; - console.log(manifests); + useEffect(() => { if (idAWB) { getManifest(); @@ -72,6 +86,8 @@ const Manifest = ({ idAWB, closePopup }) => { } }, [idAWB]); + const isLiveTracking = mappingLiveTracking(manifests?.deliveryOrder?.carrier.toLowerCase(), manifests?.waybillNumber) + return ( <> {isLoading && ( @@ -121,7 +137,7 @@ const Manifest = ({ idAWB, closePopup }) => { </div> <InformationSection manifests={manifests} /> - + <hr className='mt-4' /> {manifests?.isDelay && ( <div @@ -153,7 +169,10 @@ const Manifest = ({ idAWB, closePopup }) => { : ''; return ( - <li className='grid grid-cols-[80px_20px_1fr] gap-2 mb-6 items-start' key={index}> + <li + className='grid grid-cols-[80px_20px_1fr] gap-2 mb-6 items-start' + key={index} + > {/* Kolom 1: Tanggal + Jam */} <div className='text-sm text-gray-400 whitespace-nowrap'> {formatCustomDate(manifest.datetime)} @@ -173,7 +192,9 @@ const Manifest = ({ idAWB, closePopup }) => { {/* Kolom 3: Status dan Deskripsi */} <div> <p className='text-sm font-semibold text-green-600'> - {manifests?.deliveryOrder.carrier != 'Self Pick Up' ? capitalizeWords(manifest.status) : ''} + {manifests?.deliveryOrder.carrier != 'Self Pick Up' + ? capitalizeWords(manifest.status) + : ''} </p> <p className='text-xs text-gray-600' @@ -187,6 +208,21 @@ const Manifest = ({ idAWB, closePopup }) => { })} </ol> </div> + <div className='pt-2'> + { + isLiveTracking && + manifests?.status === 'shipment' && ( + <Link + href={isLiveTracking} + target="_blank" + rel="noopener noreferrer" + className="inline-block px-4 py-2 bg-red-600 text-white font-semibold rounded-lg shadow-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-400 focus:ring-opacity-75" + > + Live Tracking + </Link> + ) + } + </div> </BottomPopup> )} </> |
