From 4eed2e29542a9c019fcb6041ad295e85737de62f Mon Sep 17 00:00:00 2001 From: trochas Date: Thu, 8 Jan 2026 17:53:42 +0100 Subject: [PATCH] fix en cours --- front_end/src/api.ts | 2 +- front_end/src/components/login.tsx | 2 +- front_end/src/requetes.tsx | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/front_end/src/api.ts b/front_end/src/api.ts index adbf284..402e3b7 100644 --- a/front_end/src/api.ts +++ b/front_end/src/api.ts @@ -38,7 +38,7 @@ export function clearAuthToken() { export const athleteService = { // controller is mounted at /athlete - create: (data: any) => api.post("/athlete/create", data), + create: (data: any) => api.post("/api/athlete/create", data), getAll: () => api.get("/athlete/all"), getById: (id: number | string) => api.get(`/athlete/${id}`), getByKeycloakId: (keycloakId: string) => api.get(`/athlete/keycloak/${encodeURIComponent(keycloakId)}`), diff --git a/front_end/src/components/login.tsx b/front_end/src/components/login.tsx index 3633a6c..625df14 100644 --- a/front_end/src/components/login.tsx +++ b/front_end/src/components/login.tsx @@ -20,8 +20,8 @@ export const Login =() =>{ newAthlete.nom = keycloak.tokenParsed.family_name || ""; newAthlete.prenom = keycloak.tokenParsed.given_name || ""; - const newAthleteDTO: AthleteDTO =newAthlete.toDTO(); setAuthToken(keycloak.token); + const athlete: Athlete = await postAthlete(newAthlete); setUser(athlete); } catch (error) { diff --git a/front_end/src/requetes.tsx b/front_end/src/requetes.tsx index 3e969bf..4f5db60 100644 --- a/front_end/src/requetes.tsx +++ b/front_end/src/requetes.tsx @@ -128,9 +128,10 @@ export async function postActivityAPI(session: Session, activity: Activite){ export async function postAthlete(athlete: Athlete):Promise{ try { - const response = await api.post("/athlete/create/",athlete.toDTO); + //const response = await api.post("/athlete/create/",athlete.toDTO); + const response = await athleteService.create(athlete.toDTO()); console.log(response); - return response.data; + return new Athlete(response.data); } catch (error) { console.error("Error fetching coachs:", error); throw error;