From ca05a70e98e9066882de6394ffbd89db7af2cb9d Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Tue, 29 Apr 2025 09:14:44 +0700 Subject: add button live tracking --- src/lib/treckingAwb/component/Manifest.jsx | 44 +++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'src/lib') 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 }) => { - +
{manifests?.isDelay && (
{ : ''; return ( -
  • +
  • {/* Kolom 1: Tanggal + Jam */}
    {formatCustomDate(manifest.datetime)} @@ -173,7 +192,9 @@ const Manifest = ({ idAWB, closePopup }) => { {/* Kolom 3: Status dan Deskripsi */}

    - {manifests?.deliveryOrder.carrier != 'Self Pick Up' ? capitalizeWords(manifest.status) : ''} + {manifests?.deliveryOrder.carrier != 'Self Pick Up' + ? capitalizeWords(manifest.status) + : ''}

    { })}

    +
    + { + isLiveTracking && + manifests?.status === 'shipment' && ( + + Live Tracking + + ) + } +
    )} -- cgit v1.2.3