Feat: correction StatsAthletes

This commit is contained in:
Amaël Kesteman
2026-01-12 09:18:49 +01:00
parent 8c56880964
commit eadd180422
2 changed files with 7 additions and 2 deletions

View File

@@ -23,16 +23,18 @@ function StatAthlete({ athlete }: AthleteStatsProps) {
};
useEffect(() => {
console.log("useEffect déclenché, athlete.id =", athlete.id);
async function loadSessions() {
if (!athlete.id) {
console.error("Athlete ID is null");
setLoading(false);
return;
}
console.log("Début du chargement des sessions");
setLoading(true);
try {
const sessionsData = await getSessionsByAthleteId(athlete.id);
console.log("Sessions reçues de l'API:", sessionsData);
setSessions(sessionsData);
console.log("Sessions chargées:", sessionsData);
console.log("Première session:", sessionsData[0]);
@@ -42,6 +44,7 @@ function StatAthlete({ athlete }: AthleteStatsProps) {
setSessions([]);
} finally {
setLoading(false);
console.log("Fin du chargement");
}
}
@@ -49,6 +52,8 @@ function StatAthlete({ athlete }: AthleteStatsProps) {
}, [athlete.id]);
const handleCalculerStats = () => {
console.log("Sessions au moment du calcul:", sessions);
console.log("Nombre de sessions:", sessions.length);
let safeDebut = dateDebut;
let safeFin = dateFin;
if (sessions.length > 0) {

View File

@@ -402,7 +402,7 @@ 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 response = await api.get(`/athlete/${athleteId}/session`);
const sessions: Session[] = [];
const allAthletes = await getAllAthlete();