Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Alexis Leboeuf
2026-01-12 09:29:16 +01:00
2 changed files with 7 additions and 2 deletions

View File

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

View File

@@ -400,7 +400,7 @@ export async function getAllAthlete(): Promise<Athlete[]> {
export async function getSessionsByAthleteId(athleteId: number): Promise<Session[]> { export async function getSessionsByAthleteId(athleteId: number): Promise<Session[]> {
try { try {
const response = await api.get(`/athlete/athlete/${athleteId}/session`); const response = await api.get(`/athlete/${athleteId}/session`);
const sessions: Session[] = []; const sessions: Session[] = [];
const allAthletes = await getAllAthlete(); const allAthletes = await getAllAthlete();