get session de l'user dans edt
This commit is contained in:
@@ -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 [];
|
||||
|
||||
Reference in New Issue
Block a user