diff --git a/front_end/src/components/ressourcePanel.tsx b/front_end/src/components/ressourcePanel.tsx index 6a99572..c54aa2c 100644 --- a/front_end/src/components/ressourcePanel.tsx +++ b/front_end/src/components/ressourcePanel.tsx @@ -23,7 +23,6 @@ import { useKeycloak } from "@react-keycloak/web"; const[allCoachs,setAllCoachs] = useState([]); const[allSessions,setAllSessions] = useState([]); const[allLignes,setAllLignes] = useState([]); - const[allActivites,setAllActivites] = useState([]); async function updateAthletes() { diff --git a/front_end/src/requetes.tsx b/front_end/src/requetes.tsx index c21083d..c114d61 100644 --- a/front_end/src/requetes.tsx +++ b/front_end/src/requetes.tsx @@ -228,11 +228,18 @@ export async function getSessionsOfUserAPI(user:Coach|Athlete){ export async function getAllSessionsAPI():Promise{ try { const response = await sessionService.getAll(); - const sessions:Session[] = []; - response.data.forEach(sessionDTO => { - sessions.push(new Session(sessionDTO)); - - }); + const sessions = await Promise.all( + response.data.map(async sessionDTO => { + const session = new Session(sessionDTO); + const coach = await getCoachByIdAPI(sessionDTO.coachId); + + if (coach != null) { + session.coach = coach; + } + return session; + }) + ); + return sessions; } catch (error) { console.error("Error fetching sessions:", error);