refactor page to use services
This commit is contained in:
71
apps/website/lib/api/dashboard/DashboardApiClient.ts
Normal file
71
apps/website/lib/api/dashboard/DashboardApiClient.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user