diff --git a/apps/frontend/app/dashboard/layout.tsx b/apps/frontend/app/dashboard/layout.tsx index 9fae45f..3c6779e 100644 --- a/apps/frontend/app/dashboard/layout.tsx +++ b/apps/frontend/app/dashboard/layout.tsx @@ -25,6 +25,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod { name: 'Dashboard', href: '/dashboard', icon: '📊' }, { name: 'Bookings', href: '/dashboard/bookings', icon: '📦' }, { name: 'Documents', href: '/dashboard/documents', icon: '📄' }, + { name: 'Track & Trace', href: '/dashboard/track-trace', icon: '🔍' }, { name: 'Wiki', href: '/dashboard/wiki', icon: '📚' }, { name: 'My Profile', href: '/dashboard/profile', icon: '👤' }, { name: 'Organization', href: '/dashboard/settings/organization', icon: '🏢' }, diff --git a/apps/frontend/app/dashboard/track-trace/page.tsx b/apps/frontend/app/dashboard/track-trace/page.tsx new file mode 100644 index 0000000..143d759 --- /dev/null +++ b/apps/frontend/app/dashboard/track-trace/page.tsx @@ -0,0 +1,287 @@ +/** + * Track & Trace Page + * + * Allows users to track their shipments by entering tracking numbers + * and selecting the carrier. Redirects to carrier's tracking page. + */ + +'use client'; + +import { useState } from 'react'; +import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card'; +import { Input } from '@/components/ui/input'; +import { Button } from '@/components/ui/button'; + +// Carrier tracking URLs - the tracking number will be appended +const carriers = [ + { + id: 'maersk', + name: 'Maersk', + logo: '🚢', + trackingUrl: 'https://www.maersk.com/tracking/', + placeholder: 'Ex: MSKU1234567', + description: 'Container or B/L number', + }, + { + id: 'msc', + name: 'MSC', + logo: '🛳️', + trackingUrl: 'https://www.msc.com/track-a-shipment?query=', + placeholder: 'Ex: MSCU1234567', + description: 'Container, B/L or Booking number', + }, + { + id: 'cma-cgm', + name: 'CMA CGM', + logo: '⚓', + trackingUrl: 'https://www.cma-cgm.com/ebusiness/tracking/search?SearchBy=Container&Reference=', + placeholder: 'Ex: CMAU1234567', + description: 'Container or B/L number', + }, + { + id: 'hapag-lloyd', + name: 'Hapag-Lloyd', + logo: '🔷', + trackingUrl: 'https://www.hapag-lloyd.com/en/online-business/track/track-by-container-solution.html?container=', + placeholder: 'Ex: HLCU1234567', + description: 'Container number', + }, + { + id: 'cosco', + name: 'COSCO', + logo: '🌊', + trackingUrl: 'https://elines.coscoshipping.com/ebusiness/cargoTracking?trackingNumber=', + placeholder: 'Ex: COSU1234567', + description: 'Container or B/L number', + }, + { + id: 'one', + name: 'ONE (Ocean Network Express)', + logo: '🟣', + trackingUrl: 'https://ecomm.one-line.com/one-ecom/manage-shipment/cargo-tracking?trkNoParam=', + placeholder: 'Ex: ONEU1234567', + description: 'Container or B/L number', + }, + { + id: 'evergreen', + name: 'Evergreen', + logo: '🌲', + trackingUrl: 'https://www.shipmentlink.com/servlet/TDB1_CargoTracking.do?BL=', + placeholder: 'Ex: EGHU1234567', + description: 'Container or B/L number', + }, + { + id: 'yangming', + name: 'Yang Ming', + logo: '🟡', + trackingUrl: 'https://www.yangming.com/e-service/Track_Trace/track_trace_cargo_tracking.aspx?rdolType=CT&str=', + placeholder: 'Ex: YMLU1234567', + description: 'Container number', + }, + { + id: 'zim', + name: 'ZIM', + logo: '🔵', + trackingUrl: 'https://www.zim.com/tools/track-a-shipment?consnumber=', + placeholder: 'Ex: ZIMU1234567', + description: 'Container or B/L number', + }, + { + id: 'hmm', + name: 'HMM (Hyundai)', + logo: '🟠', + trackingUrl: 'https://www.hmm21.com/cms/business/ebiz/trackTrace/trackTrace/index.jsp?type=1&number=', + placeholder: 'Ex: HDMU1234567', + description: 'Container or B/L number', + }, +]; + +export default function TrackTracePage() { + const [trackingNumber, setTrackingNumber] = useState(''); + const [selectedCarrier, setSelectedCarrier] = useState(''); + const [error, setError] = useState(''); + + const handleTrack = () => { + // Validation + if (!trackingNumber.trim()) { + setError('Veuillez entrer un numéro de tracking'); + return; + } + if (!selectedCarrier) { + setError('Veuillez sélectionner un transporteur'); + return; + } + + setError(''); + + // Find the carrier and build the tracking URL + const carrier = carriers.find(c => c.id === selectedCarrier); + if (carrier) { + const trackingUrl = carrier.trackingUrl + encodeURIComponent(trackingNumber.trim()); + // Open in new tab + window.open(trackingUrl, '_blank', 'noopener,noreferrer'); + } + }; + + const handleKeyPress = (e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + handleTrack(); + } + }; + + const selectedCarrierData = carriers.find(c => c.id === selectedCarrier); + + return ( +
+ {/* Header */} +
+

Track & Trace

+

+ Suivez vos expéditions en temps réel. Entrez votre numéro de tracking et sélectionnez le transporteur. +

+
+ + {/* Search Form */} + + + + 🔍 + Rechercher une expédition + + + Entrez votre numéro de conteneur, connaissement (B/L) ou référence de booking + + + + {/* Carrier Selection */} +
+ +
+ {carriers.map(carrier => ( + + ))} +
+
+ + {/* Tracking Number Input */} +
+ +
+
+ { + setTrackingNumber(e.target.value.toUpperCase()); + setError(''); + }} + onKeyPress={handleKeyPress} + placeholder={selectedCarrierData?.placeholder || 'Ex: MSKU1234567'} + className="text-lg font-mono border-gray-300 focus:border-blue-500" + /> + {selectedCarrierData && ( +

{selectedCarrierData.description}

+ )} +
+ +
+
+ + {/* Error Message */} + {error && ( +
+

{error}

+
+ )} +
+
+ + {/* Help Section */} +
+ + + + 📦 + Numéro de conteneur + + + +

+ Format standard: 4 lettres + 7 chiffres (ex: MSKU1234567). + Le préfixe indique généralement le propriétaire du conteneur. +

+
+
+ + + + + 📋 + Connaissement (B/L) + + + +

+ Le numéro de Bill of Lading est fourni par le transporteur lors de la confirmation de booking. + Format variable selon le carrier. +

+
+
+ + + + + 📝 + Référence de booking + + + +

+ Numéro de réservation attribué par le transporteur lors de la réservation initiale de l'espace sur le navire. +

+
+
+
+ + {/* Info Box */} +
+
+ 💡 +
+

Comment fonctionne le suivi ?

+

+ Cette fonctionnalité vous redirige vers le site officiel du transporteur pour obtenir les informations + de suivi les plus récentes. Les données affichées proviennent directement du système du transporteur. +

+
+
+
+
+ ); +}