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:
Ronny
2026-04-11 19:01:01 +02:00
parent cb095126ef
commit b10f0f6ad4
3 changed files with 146 additions and 0 deletions
+21
View File
@@ -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;