/** * Dashboard Home Page * * Main dashboard with KPIs and recent bookings */ 'use client'; import { useQuery } from '@tanstack/react-query'; import { bookingsApi } from '@/lib/api'; import Link from 'next/link'; export default function DashboardPage() { const { data: bookings, isLoading } = useQuery({ queryKey: ['bookings', 'recent'], queryFn: () => bookingsApi.list({ limit: 5 }), }); const stats = [ { name: 'Total Bookings', value: bookings?.total || 0, icon: '📦', change: '+12%' }, { name: 'This Month', value: '8', icon: '📅', change: '+4.3%' }, { name: 'Pending', value: '3', icon: '⏳', change: '-2%' }, { name: 'Completed', value: '45', icon: '✅', change: '+8%' }, ]; return (
{/* Welcome Section */}

Welcome back!

Here's what's happening with your shipments today.

{/* KPI Cards */}
{stats.map((stat) => (

{stat.name}

{stat.value}

{stat.icon}
{stat.change} vs last month
))}
{/* Quick Actions */}
🔍

Search Rates

Find the best shipping rates

New Booking

Create a new shipment

📋

View Bookings

Track all your shipments

{/* Recent Bookings */}

Recent Bookings

View all →
{isLoading ? (
Loading bookings...
) : bookings?.data && bookings.data.length > 0 ? ( bookings.data.map((booking) => (
{booking.bookingNumber} {booking.status}

{booking.cargoDescription}

{new Date(booking.createdAt).toLocaleDateString()}

)) ) : (

No bookings yet

Search for rates
)}
); }