get session de l'user dans edt

This commit is contained in:
trochas
2026-01-10 12:47:08 +01:00
parent fca7362bb7
commit 8d844d2b2f
6 changed files with 68 additions and 23 deletions

View File

@@ -272,15 +272,22 @@ export async function getCoachByIdAPI(id:number|null): Promise<Coach|null> {
}
//SESSION
export async function getSessionsOfUserAPI(user:Coach|Athlete){
export async function getSessionsOfUserAPI(user:User): Promise<Session[]>{
try {
var sessionsDTO:SessionDTO[] = []
if (user instanceof Coach) {
const response = await coachService.getSessionsForCoach(user.id); //TODO
return response.data;
sessionsDTO = response.data;
}else if (user instanceof Athlete) {
const response = await athleteService.getSessionsForAthlete(user.id); //TODO
return response.data;
sessionsDTO = response.data;
}
const sessions:Session[] = [];
sessionsDTO.forEach(sessionDTO => {
sessions.push(new Session(sessionDTO));
});
return sessions;
}catch (error) {
console.error("Error fetching sessions for user:", error);
return [];