merge + clean
This commit is contained in:
@@ -219,28 +219,11 @@ export async function postAthlete(athlete: Athlete):Promise<Athlete>{
|
||||
|
||||
export async function postSession(session: Session){
|
||||
try {
|
||||
/* const data = {
|
||||
name: session.name,
|
||||
creneau: session.creneau, // string ISO OK
|
||||
duree: session.duree,
|
||||
isRecurrent: session.isRecurrent,
|
||||
|
||||
coachId: session.coach?.id,
|
||||
groupe: session.groupe ? session.groupe : undefined,
|
||||
}*/
|
||||
|
||||
const response = await sessionService.create(session.toDTO());
|
||||
session.id = response.data.id; //TODO ?
|
||||
|
||||
session.activites.forEach(activite => {
|
||||
const data2 = {
|
||||
name: activite.nom,
|
||||
duree: activite.duree,
|
||||
date: activite.data,
|
||||
theme: activite.theme,
|
||||
sessionId: session.id, //TODO
|
||||
}
|
||||
activiteService.create(data2);
|
||||
activiteService.create(activite.toDTO());
|
||||
// console.log("Session créée");
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -300,9 +283,14 @@ export async function getSessionsOfUserAPI(user:User): Promise<Session[]>{
|
||||
sessionsDTO = response.data;
|
||||
}
|
||||
const sessions:Session[] = [];
|
||||
sessionsDTO.forEach(sessionDTO => {
|
||||
sessions.push(new Session(sessionDTO));
|
||||
});
|
||||
for (const sessionDTO of sessionsDTO) {
|
||||
const session = new Session(sessionDTO);
|
||||
const coach = await getCoachByIdAPI(sessionDTO.coachId);
|
||||
if(coach!=null){
|
||||
session.coach = coach;
|
||||
}
|
||||
sessions.push(session);
|
||||
}
|
||||
return sessions;
|
||||
|
||||
}catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user