Skip to content

Frontend: Build Shipment Tracking Page with Live Map #498

@mftee

Description

@mftee

Title: Create Real-time Shipment Tracking Interface with Interactive Map

Description:
Implement a comprehensive shipment tracking page with live map visualization, status timeline, document uploads, and real-time updates. This page allows users to monitor shipment progress and view detailed information.

Page Route: /tracking/[shipmentId]

Requirements:

  • Interactive map showing shipment route
  • Real-time location updates
  • Status timeline/progress tracker
  • Shipment details panel
  • Document viewer
  • Communication panel (chat with carrier)
  • Responsive design

Page Sections:

1. Map Section (Primary)

  • Full-screen interactive map (Mapbox or Leaflet)
  • Origin and destination markers
  • Current location marker (moving/animated)
  • Route polyline
  • Real-time position updates via WebSocket
  • Zoom controls
  • Toggle satellite/street view
  • Estimated time remaining overlay

2. Shipment Details Sidebar

  • Shipment ID and title
  • Status badge (in transit, delivered, etc.)
  • Origin address with icon
  • Destination address with icon
  • Carrier information (name, photo, rating)
  • Vehicle details (type, license plate)
  • Estimated delivery time
  • Distance remaining
  • Quick actions (Contact Carrier, Report Issue)

3. Status Timeline

  • Vertical timeline showing:
    • Shipment Created (timestamp, location)
    • Picked Up (timestamp, location)
    • In Transit checkpoints (multiple)
    • Out for Delivery
    • Delivered (or current status)
  • Each step with icon, timestamp, and notes
  • Completed steps in green, current in blue, pending in gray

4. Documents Section

  • List of uploaded documents
  • Document types (Bill of Lading, POD, etc.)
  • Download buttons
  • Preview modal for PDFs/images
  • Upload new document button (if authorized)

5. Activity Feed

  • Recent updates:
    • Status changes
    • Location updates
    • Messages
    • Document uploads
  • Timestamps with relative time ("2 hours ago")

6. Communication Panel (Collapsible)

  • Chat interface with carrier
  • Message history
  • Send message input
  • File attachment option
  • Typing indicators
  • Read receipts

Components to Create:

/components/tracking/
├── TrackingMap.tsx (main map component)
├── MapMarker.tsx (custom markers, reusable)
├── RoutePolyline.tsx
├── ShipmentDetailsSidebar.tsx
├── StatusTimeline.tsx
├── TimelineStep.tsx (reusable)
├── DocumentsList.tsx
├── DocumentPreviewModal.tsx
├── ActivityFeedPanel.tsx
├── ChatPanel.tsx
├── ChatMessage.tsx (reusable)
├── ShipmentInfoCard.tsx (reusable)
└── QuickActionsMenu.tsx

/components/shared/
├── Map.tsx (reusable map wrapper)
├── FileUpload.tsx (reusable)
└── Modal.tsx (reusable)

Technical Requirements:

  • Use react-leaflet for maps (or Mapbox)
  • WebSocket connection with Socket.io-client for real-time updates
  • react-pdf for PDF document preview
  • Radix UI for modals and dialogs
  • Handle map performance with large routes

Real-time Updates:

  • Subscribe to WebSocket events for location updates
  • Join specific shipment room: shipment-${shipmentId}
  • Listen for events: location_update, status_update, new_message
  • Update map marker position smoothly
  • Show connection status indicator

Map Features:

  • Custom icons for origin, destination, and current location
  • Polyline showing planned route
  • Auto-center and zoom to fit route
  • Click markers for info popups
  • Responsive map that resizes with sidebar

Status Workflow:
Created → Posted → Assigned → Picked Up → In Transit → Out for Delivery → Delivered

Acceptance Criteria:

  • Interactive map with zoom/pan controls
  • Real-time location marker updates
  • Route polyline displays correctly
  • Status timeline shows all events
  • Shipment details display accurately
  • Documents list with download functionality
  • Chat panel functional (send/receive messages)
  • WebSocket connection for real-time updates
  • Responsive design (mobile: map fullscreen, details below)
  • Loading states for map and data
  • Error handling (shipment not found, connection lost)
  • Print-friendly view option
  • Share tracking link button
  • TypeScript: no type errors
  • Performance: smooth map rendering

Environment Variables:

NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token
NEXT_PUBLIC_SOCKET_URL=ws://localhost:3001

Testing Requirements:

  • Test map renders on different devices
  • Test real-time updates simulation
  • Test with different shipment statuses
  • Test document preview/download
  • Test chat message sending
  • Test responsive layout
  • Test WebSocket reconnection

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions