150 lines
3.3 KiB
TypeScript
150 lines
3.3 KiB
TypeScript
/**
|
|
* Dashboard API
|
|
*
|
|
* Endpoints for dashboard analytics and KPIs
|
|
*/
|
|
|
|
import { get } from './client';
|
|
|
|
/**
|
|
* Dashboard KPIs Response
|
|
*/
|
|
export interface DashboardKPIs {
|
|
bookingsThisMonth: number;
|
|
bookingsThisMonthChange: number;
|
|
/** Volume LCL du mois, en CBM. */
|
|
volumeCBM: number;
|
|
volumeCBMChange: number;
|
|
/** Commission Xpeditis sur les reservations acceptees, en EUR. */
|
|
estimatedRevenue: number;
|
|
estimatedRevenueChange: number;
|
|
pendingConfirmations: number;
|
|
pendingConfirmationsChange: number;
|
|
}
|
|
|
|
/**
|
|
* Bookings Chart Data
|
|
*/
|
|
export interface BookingsChartData {
|
|
/** Cles de mois ISO `YYYY-MM` ; mises en forme cote client. */
|
|
labels: string[];
|
|
data: number[];
|
|
}
|
|
|
|
/**
|
|
* Trade Lane Data
|
|
*/
|
|
export interface TradeLane {
|
|
route: string;
|
|
bookingCount: number;
|
|
originPort: string;
|
|
destinationPort: string;
|
|
totalVolumeCBM: number;
|
|
avgPrice: number;
|
|
}
|
|
|
|
/**
|
|
* Dashboard Alert
|
|
*/
|
|
export interface DashboardAlert {
|
|
id: string;
|
|
/** Determine vers quel ecran l'alerte renvoie. */
|
|
type: 'delay' | 'confirmation' | 'document' | 'payment' | 'info';
|
|
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
/** Cles de traduction resolues par le client. */
|
|
titleKey: string;
|
|
messageKey: string;
|
|
messageParams?: Record<string, string | number>;
|
|
bookingId?: string;
|
|
bookingNumber?: string;
|
|
createdAt: string;
|
|
}
|
|
|
|
/**
|
|
* Get dashboard KPIs
|
|
* GET /api/v1/dashboard/kpis
|
|
*/
|
|
export async function getKPIs(): Promise<DashboardKPIs> {
|
|
return get<DashboardKPIs>('/api/v1/dashboard/kpis');
|
|
}
|
|
|
|
/**
|
|
* Get bookings chart data (6 months)
|
|
* GET /api/v1/dashboard/bookings-chart
|
|
*/
|
|
export async function getBookingsChart(): Promise<BookingsChartData> {
|
|
return get<BookingsChartData>('/api/v1/dashboard/bookings-chart');
|
|
}
|
|
|
|
/**
|
|
* Get top 5 trade lanes
|
|
* GET /api/v1/dashboard/top-trade-lanes
|
|
*/
|
|
export async function getTopTradeLanes(): Promise<TradeLane[]> {
|
|
return get<TradeLane[]>('/api/v1/dashboard/top-trade-lanes');
|
|
}
|
|
|
|
/**
|
|
* Get dashboard alerts
|
|
* GET /api/v1/dashboard/alerts
|
|
*/
|
|
export async function getAlerts(): Promise<DashboardAlert[]> {
|
|
return get<DashboardAlert[]>('/api/v1/dashboard/alerts');
|
|
}
|
|
|
|
/**
|
|
* CSV Booking KPIs Response
|
|
*/
|
|
export interface CsvBookingKPIs {
|
|
totalAccepted: number;
|
|
totalRejected: number;
|
|
totalPending: number;
|
|
totalWeightAcceptedKG: number;
|
|
totalVolumeAcceptedCBM: number;
|
|
acceptanceRate: number;
|
|
acceptedThisMonth: number;
|
|
rejectedThisMonth: number;
|
|
}
|
|
|
|
/**
|
|
* Top Carrier Data
|
|
*/
|
|
export interface TopCarrier {
|
|
carrierName: string;
|
|
totalBookings: number;
|
|
acceptedBookings: number;
|
|
rejectedBookings: number;
|
|
acceptanceRate: number;
|
|
totalWeightKG: number;
|
|
totalVolumeCBM: number;
|
|
avgPriceUSD: number;
|
|
}
|
|
|
|
/**
|
|
* Get CSV booking KPIs
|
|
* GET /api/v1/dashboard/csv-booking-kpis
|
|
*/
|
|
export async function getCsvBookingKPIs(): Promise<CsvBookingKPIs> {
|
|
return get<CsvBookingKPIs>('/api/v1/dashboard/csv-booking-kpis');
|
|
}
|
|
|
|
/**
|
|
* Get top carriers (top 5 by booking count)
|
|
* GET /api/v1/dashboard/top-carriers
|
|
*/
|
|
export async function getTopCarriers(): Promise<TopCarrier[]> {
|
|
return get<TopCarrier[]>('/api/v1/dashboard/top-carriers');
|
|
}
|
|
|
|
/**
|
|
* Export all dashboard APIs
|
|
*/
|
|
export const dashboardApi = {
|
|
getKPIs,
|
|
getBookingsChart,
|
|
getTopTradeLanes,
|
|
getAlerts,
|
|
getCsvBookingKPIs,
|
|
getTopCarriers,
|
|
};
|