xpeditis2.0/apps/frontend/lib/api/dashboard.ts
David 08787c89c8
Some checks failed
Dev CI / Unit Tests (${{ matrix.app }}) (backend) (push) Blocked by required conditions
Dev CI / Unit Tests (${{ matrix.app }}) (frontend) (push) Blocked by required conditions
Dev CI / Notify Failure (push) Blocked by required conditions
Dev CI / Quality (${{ matrix.app }}) (backend) (push) Has been cancelled
Dev CI / Quality (${{ matrix.app }}) (frontend) (push) Has been cancelled
chore: sync full codebase from cicd branch
Aligns dev with the complete application codebase (cicd branch).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 12:56:16 +02:00

73 lines
1.5 KiB
TypeScript

/**
* Dashboard API Client
*/
import { get } from '../../src/lib/api/client';
export interface DashboardKPIs {
bookingsThisMonth: number;
totalTEUs: number;
estimatedRevenue: number;
pendingConfirmations: number;
bookingsThisMonthChange: number;
totalTEUsChange: number;
estimatedRevenueChange: number;
pendingConfirmationsChange: number;
}
export interface BookingsChartData {
labels: string[];
data: number[];
}
export interface TopTradeLane {
route: string;
originPort: string;
destinationPort: string;
bookingCount: number;
totalTEUs: number;
avgPrice: number;
}
export interface DashboardAlert {
id: string;
type: 'delay' | 'confirmation' | 'document' | 'payment' | 'info';
severity: 'low' | 'medium' | 'high' | 'critical';
title: string;
message: string;
bookingId?: string;
bookingNumber?: string;
createdAt: string;
isRead: boolean;
}
export const dashboardApi = {
/**
* Get dashboard KPIs
*/
async getKPIs(): Promise<DashboardKPIs> {
return get<DashboardKPIs>('/api/v1/dashboard/kpis');
},
/**
* Get bookings chart data
*/
async getBookingsChart(): Promise<BookingsChartData> {
return get<BookingsChartData>('/api/v1/dashboard/bookings-chart');
},
/**
* Get top trade lanes
*/
async getTopTradeLanes(): Promise<TopTradeLane[]> {
return get<TopTradeLane[]>('/api/v1/dashboard/top-trade-lanes');
},
/**
* Get dashboard alerts
*/
async getAlerts(): Promise<DashboardAlert[]> {
return get<DashboardAlert[]>('/api/v1/dashboard/alerts');
},
};