Added Keycloak related endpoints and other ones

This commit is contained in:
Alexis Leboeuf
2026-01-08 15:47:46 +01:00
parent e72243d355
commit 95ce13181f
5 changed files with 46 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import axios from "axios";
import keycloak from "./keycloak";
import { get } from "http";
const api = axios.create({
@@ -17,7 +18,6 @@ api.interceptors.request.use((config) => {
if (keycloak?.token) {
// eslint-disable-next-line no-param-reassign
config.headers.Authorization = `Bearer ${keycloak.token}`;
console.log(config.headers.Authorization);
}
return config;
});
@@ -36,11 +36,13 @@ export function clearAuthToken() {
}
export const athleteService = {
create: (data: any) => api.post("/athletes/create", data),
getAll: () => api.get("/athletes/all"),
getByKeycloakId: (id: number | string) => api.get(`/athletes/${id}`),
update: (id: number | string, data: any) => api.put(`/athletes/${id}`, data),
delete: (id: number | string) => api.delete(`/athletes/${id}`),
// controller is mounted at /athlete
create: (data: any) => api.post("/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)}`),
update: (id: number | string, data: any) => api.put(`/athlete/${id}`, data),
delete: (id: number | string) => api.delete(`/athlete/${id}`),
// session-related endpoints exposed by AthleteResource
getSessionsForAthlete: (athleteId: number | string) => api.get(`/athletes/athlete/${athleteId}/session`),
@@ -57,6 +59,7 @@ export const activiteService = {
getById: (id: number | string) => api.get(`/activite/${id}`),
getAll: () => api.get(`/activite/all`),
getByTheme: (theme: string) => api.get(`/activite/theme/${encodeURIComponent(theme)}`),
getDataActivite: (id: number | string) => api.get(`/activite/${id}`),
};
export const sessionService = {
@@ -83,15 +86,16 @@ export const coachService = {
getByKeycloakId: (id: number | string) => api.get(`/coach/${id}`),
update: (id: number | string, data: any) => api.put(`/coach/update/${id}`, data),
delete: (id: number | string) => api.delete(`/coach/delete/${id}`),
getSessionsForCoach: (coachId: number | string) => api.get(`/coach/${coachId}/session`),
// plural convenience
createPlural: (data: any) => api.post(`/coaches`, data),
getAllPlural: () => api.get(`/coaches`),
};
export const userService = {
getByKeycloakId: (id: number | string) => api.get(`/users/${id}`),
getAll: () => api.get(`/users`),
getByKeycloakId: (keycloak_id: string) => api.get(`/users/${keycloak_id}`),
getAll: () => api.get(`/users/all`),
sync: () => api.post(`/users/sync`),
};
export default api;