Files
gridpilot.gg/apps/website/lib/api/dashboard/DashboardApiClient.ts

71 lines
1.4 KiB
TypeScript

import { BaseApiClient } from '../base/BaseApiClient';
// DTOs
export type DriverDto = {
id: string;
name: string;
avatarUrl: string;
country: string;
totalRaces: number;
wins: number;
podiums: number;
rating: number;
globalRank: number;
consistency: number;
};
export type RaceDto = {
id: string;
track: string;
car: string;
scheduledAt: string; // ISO date string
isMyLeague: boolean;
leagueName?: string;
};
export type LeagueStandingDto = {
leagueId: string;
leagueName: string;
position: number;
points: number;
totalDrivers: number;
};
export type FeedItemDto = {
id: string;
type: string;
headline: string;
body: string | null;
timestamp: string; // ISO date string
ctaHref?: string;
ctaLabel?: string;
};
export type FriendDto = {
id: string;
name: string;
avatarUrl: string;
country: string;
};
export type DashboardOverviewDto = {
currentDriver: DriverDto;
nextRace: RaceDto | null;
upcomingRaces: RaceDto[];
leagueStandings: LeagueStandingDto[];
feedItems: FeedItemDto[];
friends: FriendDto[];
activeLeaguesCount: number;
};
/**
* Dashboard API Client
*
* Handles dashboard overview data aggregation.
*/
export class DashboardApiClient extends BaseApiClient {
/** Get dashboard overview data */
getDashboardOverview(): Promise<DashboardOverviewDto> {
return this.get<DashboardOverviewDto>('/dashboard/overview');
}
}