fix en cours
This commit is contained in:
@@ -38,7 +38,7 @@ export function clearAuthToken() {
|
|||||||
|
|
||||||
export const athleteService = {
|
export const athleteService = {
|
||||||
// controller is mounted at /athlete
|
// controller is mounted at /athlete
|
||||||
create: (data: any) => api.post<AthleteDTO>("/athlete/create", data),
|
create: (data: any) => api.post<AthleteDTO>("/api/athlete/create", data),
|
||||||
getAll: () => api.get("/athlete/all"),
|
getAll: () => api.get("/athlete/all"),
|
||||||
getById: (id: number | string) => api.get(`/athlete/${id}`),
|
getById: (id: number | string) => api.get(`/athlete/${id}`),
|
||||||
getByKeycloakId: (keycloakId: string) => api.get(`/athlete/keycloak/${encodeURIComponent(keycloakId)}`),
|
getByKeycloakId: (keycloakId: string) => api.get(`/athlete/keycloak/${encodeURIComponent(keycloakId)}`),
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ export const Login =() =>{
|
|||||||
newAthlete.nom = keycloak.tokenParsed.family_name || "";
|
newAthlete.nom = keycloak.tokenParsed.family_name || "";
|
||||||
newAthlete.prenom = keycloak.tokenParsed.given_name || "";
|
newAthlete.prenom = keycloak.tokenParsed.given_name || "";
|
||||||
|
|
||||||
const newAthleteDTO: AthleteDTO =newAthlete.toDTO();
|
|
||||||
setAuthToken(keycloak.token);
|
setAuthToken(keycloak.token);
|
||||||
|
|
||||||
const athlete: Athlete = await postAthlete(newAthlete);
|
const athlete: Athlete = await postAthlete(newAthlete);
|
||||||
setUser(athlete);
|
setUser(athlete);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -128,9 +128,10 @@ export async function postActivityAPI(session: Session, activity: Activite){
|
|||||||
|
|
||||||
export async function postAthlete(athlete: Athlete):Promise<Athlete>{
|
export async function postAthlete(athlete: Athlete):Promise<Athlete>{
|
||||||
try {
|
try {
|
||||||
const response = await api.post<Athlete>("/athlete/create/",athlete.toDTO);
|
//const response = await api.post<Athlete>("/athlete/create/",athlete.toDTO);
|
||||||
|
const response = await athleteService.create(athlete.toDTO());
|
||||||
console.log(response);
|
console.log(response);
|
||||||
return response.data;
|
return new Athlete(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching coachs:", error);
|
console.error("Error fetching coachs:", error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user