feat: add /api/dashboard endpoint with hero match, stats, streak, nudges
Returns next tippable match (hero), user rank/points from leaderboard, consecutive-tip streak, and up to 3 contextual nudges in one request. Mounts at /api/dashboard; adds getDashboard() + DashboardData type to the frontend API client. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,9 @@ export const api = {
|
||||
body: JSON.stringify({ team }),
|
||||
}),
|
||||
|
||||
// Dashboard
|
||||
getDashboard: () => request<DashboardData>('/dashboard'),
|
||||
|
||||
// Admin
|
||||
syncMatches: () =>
|
||||
request<{ success: boolean; total: number; created: number; updated: number }>(
|
||||
@@ -67,6 +70,24 @@ export const api = {
|
||||
};
|
||||
|
||||
// Types (gespiegelt vom Backend)
|
||||
export interface DashboardData {
|
||||
hero: {
|
||||
match: {
|
||||
id: number;
|
||||
homeTeam: { name: string; shortName: string; crest: string | null };
|
||||
awayTeam: { name: string; shortName: string; crest: string | null };
|
||||
utcDate: string;
|
||||
status: string;
|
||||
minutesUntilKickoff: number;
|
||||
};
|
||||
userTip: { home: number; away: number } | null;
|
||||
tippable: boolean;
|
||||
} | null;
|
||||
stats: { rank: number | null; totalPoints: number; streak: number };
|
||||
nudges: Array<{ type: string; text: string; matchId?: number }>;
|
||||
}
|
||||
|
||||
|
||||
export interface Match {
|
||||
id: number;
|
||||
externalId: number;
|
||||
|
||||
Reference in New Issue
Block a user