diff --git a/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java b/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java index 0a64d1e..5fd3a74 100644 --- a/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java +++ b/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java @@ -43,11 +43,8 @@ public class SessionResource { @PreAuthorize("hasRole('coach')") public ResponseEntity create(@RequestBody SessionDTO dto) { try { - System.out.println("ALLEZ ZYWOO TOP 1"); Session session = maptoEntity(dto); - System.out.println("ID COACH: " + dto.getCoachId()); Coach c = coachDAO.findById(dto.getCoachId()).orElse(null); - System.out.println("IS COACH FOUND ? " + (c != null)); session.setCoach(c); sessionDAO.save(session); return ResponseEntity.status(HttpStatus.CREATED).body(maptoDTO(session)); @@ -149,22 +146,7 @@ public class SessionResource { session.setCreneau(dto.getCreneau()); session.setDuree(dto.getDuree()); session.setGroupe(dto.getGroupe()); - // Coach - if (dto.getCoachId() != null) { - Coach coach = new Coach(); - coach.setId(dto.getCoachId()); - session.setCoach(coach); - } - // Athletes - if (dto.getAthleteIds() != null) { - List athletes = athleteDAO.findAllById(dto.getAthleteIds()); - session.setAthletes(athletes); - } - // Activites - if (dto.getActiviteIds() != null) { - List activites = activiteDAO.findAllById(dto.getActiviteIds()); - session.setActivites(activites); - } + return session; } } diff --git a/front_end/src/components/createSession.tsx b/front_end/src/components/createSession.tsx index a68ecc8..9a0f60c 100644 --- a/front_end/src/components/createSession.tsx +++ b/front_end/src/components/createSession.tsx @@ -35,6 +35,7 @@ export const CreateSession = () => { async function handleCreateSession() { if(user instanceof Coach){ + session.name = name; session.groupe = groupe; session.creneau = creneau; session.duree = duree; diff --git a/front_end/src/requetes.tsx b/front_end/src/requetes.tsx index 2f293ab..c733157 100644 --- a/front_end/src/requetes.tsx +++ b/front_end/src/requetes.tsx @@ -22,12 +22,14 @@ export async function loginOrRegister(keycloak:Keycloak): Promise{ const roles = keycloak.tokenParsed?.realm_access?.roles if(roles!=null){ if(roles.includes("admin")){ - const id = keycloak.tokenParsed?.sub; - if(id!=null){ - const response = await athleteService.create(id); - const admin = new Admin(response.data); - return admin; - } + const newAdmin: Admin = new Admin(); + newAdmin.keycloakId = keycloak.tokenParsed.sub || ""; + newAdmin.email = keycloak.tokenParsed.email || ""; + newAdmin.nom = keycloak.tokenParsed.family_name || ""; + newAdmin.prenom = keycloak.tokenParsed.given_name || ""; + const response = await athleteService.create(newAdmin.toDTO()); + const admin = new Admin(response.data); + return admin; } else if(roles.includes("coach")){ const newCoach: Coach = new Coach();