Feat: correction StatsAthletes
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user