Feat: Stats athlètes fonctionnel

This commit is contained in:
Amaël Kesteman
2026-01-11 21:27:32 +01:00
parent b9e67589ed
commit cbd53ba471
6 changed files with 129 additions and 43 deletions

View File

@@ -361,3 +361,29 @@ export async function getAllAthlete(): Promise<Athlete[]> {
}
}
export async function getSessionsByAthleteId(athleteId: number): Promise<Session[]> {
try {
const response = await api.get(`/athlete/athlete/${athleteId}/session`);
const sessions: Session[] = [];
const allAthletes = await getAllAthlete();
response.data.forEach((sessionDTO: SessionDTO) => {
const session = new Session(sessionDTO);
if (sessionDTO.athleteIds && sessionDTO.athleteIds.length > 0) {
session.athletes = allAthletes.filter(a =>
sessionDTO.athleteIds.includes(a.id!)
);
}
sessions.push(session);
});
console.log(`Sessions chargées pour l'athlète ${athleteId}:`, sessions);
return sessions;
} catch (error) {
console.error("Error fetching sessions for athlete:", error);
return [];
}
}