ressourcePanel getAll
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>("/athlete/create", data),
|
||||||
getAll: () => api.get("/athlete/all"),
|
getAll: () => api.get<AthleteDTO[]>("/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)}`),
|
||||||
update: (id: number | string, data: any) => api.put(`/athlete/${id}`, data),
|
update: (id: number | string, data: any) => api.put(`/athlete/${id}`, data),
|
||||||
@@ -58,7 +58,7 @@ export const activiteService = {
|
|||||||
delete: (id: number | string) => api.delete(`/activite/delete/${id}`),
|
delete: (id: number | string) => api.delete(`/activite/delete/${id}`),
|
||||||
update: (id: number | string, data: ActiviteDTO) => api.post(`/activite/update/${id}`, data),
|
update: (id: number | string, data: ActiviteDTO) => api.post(`/activite/update/${id}`, data),
|
||||||
getById: (id: number | string) => api.get(`/activite/${id}`),
|
getById: (id: number | string) => api.get(`/activite/${id}`),
|
||||||
getAll: () => api.get(`/activite/all`),
|
getAll: () => api.get<ActiviteDTO[]>(`/activite/all`),
|
||||||
getByTheme: (theme: string) => api.get(`/activite/theme/${encodeURIComponent(theme)}`),
|
getByTheme: (theme: string) => api.get(`/activite/theme/${encodeURIComponent(theme)}`),
|
||||||
getDataActivite: (id: number | string) => api.get(`/activite/${id}`),
|
getDataActivite: (id: number | string) => api.get(`/activite/${id}`),
|
||||||
};
|
};
|
||||||
@@ -80,7 +80,7 @@ export const sessionService = {
|
|||||||
export const coachService = {
|
export const coachService = {
|
||||||
// controller doesn't declare a class-level path consistently; support both common patterns
|
// controller doesn't declare a class-level path consistently; support both common patterns
|
||||||
create: (data: any) => api.post<CoachDTO>(`/coach/create`, data),
|
create: (data: any) => api.post<CoachDTO>(`/coach/create`, data),
|
||||||
getAll: () => api.get(`/coach/all`),
|
getAll: () => api.get<CoachDTO[]>(`/coach/all`),
|
||||||
getById: (id: number) => api.get(`/coach/${id}`),
|
getById: (id: number) => api.get(`/coach/${id}`),
|
||||||
getByKeycloakId: (keycloakId: string) => api.get(`/coach/keycloak/${keycloakId}`),
|
getByKeycloakId: (keycloakId: string) => api.get(`/coach/keycloak/${keycloakId}`),
|
||||||
update: (id: number | string, data: any) => api.put(`/coach/update/${id}`, data),
|
update: (id: number | string, data: any) => api.put(`/coach/update/${id}`, data),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { keyboard } from "@testing-library/user-event/dist/keyboard";
|
|||||||
import ObjectSession from "./object/session";
|
import ObjectSession from "./object/session";
|
||||||
import ObjectActivite from "./object/activite";
|
import ObjectActivite from "./object/activite";
|
||||||
import ObjectUser from "./object/user";
|
import ObjectUser from "./object/user";
|
||||||
import { getAllSessionsAPI } from "../requetes";
|
import { getAllActiviteAPI, getAllAthlete, getAllCoach, getAllSessionsAPI } from "../requetes";
|
||||||
import { useKeycloak } from "@react-keycloak/web";
|
import { useKeycloak } from "@react-keycloak/web";
|
||||||
import ObjectLigne from "./object/lignes";
|
import ObjectLigne from "./object/lignes";
|
||||||
|
|
||||||
@@ -27,13 +27,19 @@ import ObjectLigne from "./object/lignes";
|
|||||||
|
|
||||||
|
|
||||||
async function updateAthletes() {
|
async function updateAthletes() {
|
||||||
|
const athletes:Athlete[] = await getAllAthlete();
|
||||||
|
setAllAthletes(athletes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function updateCoachs() {
|
async function updateCoachs() {
|
||||||
|
const coachs:Coach[] = await getAllCoach();
|
||||||
|
setAllCoachs(coachs);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateActivites() {
|
async function updateActivites() {
|
||||||
|
const activites:Activite[] = await getAllActiviteAPI();
|
||||||
|
setAllActivites(activites);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateSessions() {
|
async function updateSessions() {
|
||||||
|
|||||||
@@ -189,6 +189,21 @@ export async function createActivityAPI(activity: Activite):Promise<Activite>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAllActiviteAPI(): Promise<Activite[]> {
|
||||||
|
try {
|
||||||
|
const response = await activiteService.getAll();
|
||||||
|
const activites:Activite[] = []
|
||||||
|
response.data.forEach(dto => {
|
||||||
|
activites.push(new Activite(dto));
|
||||||
|
});
|
||||||
|
return activites;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching users:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
@@ -319,9 +334,12 @@ export async function getAllSessionsAPI():Promise<Session[]>{
|
|||||||
//COACH
|
//COACH
|
||||||
export async function getAllCoach(): Promise<Coach[]> {
|
export async function getAllCoach(): Promise<Coach[]> {
|
||||||
try {
|
try {
|
||||||
const response = await api.get<Coach[]>("/coach/all");
|
const response = await coachService.getAll();
|
||||||
console.log(response);
|
const coachs:Coach[] = []
|
||||||
return response.data;
|
response.data.forEach(dto => {
|
||||||
|
coachs.push(new Coach(dto));
|
||||||
|
});
|
||||||
|
return coachs;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching coachs:", error);
|
console.error("Error fetching coachs:", error);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -332,7 +350,11 @@ export async function getAllCoach(): Promise<Coach[]> {
|
|||||||
export async function getAllAthlete(): Promise<Athlete[]> {
|
export async function getAllAthlete(): Promise<Athlete[]> {
|
||||||
try {
|
try {
|
||||||
const response = await athleteService.getAll();
|
const response = await athleteService.getAll();
|
||||||
return response.data;
|
const athletes:Athlete[] = []
|
||||||
|
response.data.forEach(dto => {
|
||||||
|
athletes.push(new Athlete(dto));
|
||||||
|
});
|
||||||
|
return athletes;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching users:", error);
|
console.error("Error fetching users:", error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user