From c368462ccb6fb8897fd8c14497845032a0c12c59 Mon Sep 17 00:00:00 2001 From: tuanvu Date: Fri, 9 Jan 2026 13:38:54 +0100 Subject: [PATCH 1/2] petit commit --- .../FrisbYEE/rest/SessionResource.java | 2 +- front_end/src/components/ressourcePanel.tsx | 1 + front_end/src/requetes.tsx | 35 ++++++++----------- 3 files changed, 17 insertions(+), 21 deletions(-) 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 f313d1c..91c4ce7 100644 --- a/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java +++ b/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java @@ -54,7 +54,7 @@ public class SessionResource { } @GetMapping("/all") - @PreAuthorize("hasRole('coach') or hasRole('athlete')") + @PreAuthorize("hasRole('admin') or hasRole('coach') or hasRole('athlete')") public ResponseEntity> getAll() { List sessions = sessionDAO.findAll(); List dtos = new ArrayList<>(); diff --git a/front_end/src/components/ressourcePanel.tsx b/front_end/src/components/ressourcePanel.tsx index cdadcde..58cd120 100644 --- a/front_end/src/components/ressourcePanel.tsx +++ b/front_end/src/components/ressourcePanel.tsx @@ -22,6 +22,7 @@ import { useKeycloak } from "@react-keycloak/web"; const[allCoachs,setAllCoachs] = useState([]); const[allSessions,setAllSessions] = useState([]); const[allLignes,setAllLignes] = useState([]); + const[allActivites,setAllActivites] = useState([]); async function updateAthletes() { diff --git a/front_end/src/requetes.tsx b/front_end/src/requetes.tsx index 6b3c4a8..eae0850 100644 --- a/front_end/src/requetes.tsx +++ b/front_end/src/requetes.tsx @@ -76,7 +76,6 @@ export async function updateActivitiesOfSessionAPI(session:Session,activities:Ac } catch (error) { console.error("Error fetching activities for session:", error); } - } export async function subscribeSessionAPI(user:User, session:Session):Promise{ @@ -103,11 +102,7 @@ export async function unsubscribeSessionAPI(user:User, session:Session):Promise< } } -// ADMIN : -export async function updateAllUserAPI(){ - -} // POST ///////////////////////////////////////////////////////// @@ -123,7 +118,8 @@ export async function createSessionAPI(session: Session): Promise { } } -export async function postActivityAPI(session: Session, activity: Activite){ + +export async function createActivityAPI(session: Session, activity: Activite){ try { const response = await api.post(`/session/${session.id}/activities`, activity); return response.data; @@ -176,7 +172,8 @@ export async function postSession(session: Session){ } } -export async function postAdmin(athlete: Admin):Promise{ +// SET ///////////////////////////////////////////////////////// +export async function createAdminAPI(athlete: Admin):Promise{ try { const response = await api.post("/admin/create/",athlete); console.log(response); @@ -187,22 +184,20 @@ export async function postAdmin(athlete: Admin):Promise{ } } -// SET ///////////////////////////////////////////////////////// - -//ADMIN -export async function setUserNameAPI(user: User, name: string){ - -} - -//COACH -export async function setSessionCreneauAPI(session: Session, date:Date){ - -} - //GET ///////////////////////////////////////////////////////// -//SESSION +//USER +export async function getAllUserAPI(): Promise { + try{ + const response = await api.get("/users/all"); + return response.data; + }catch (error) { + console.error("Error fetching users:", error); + throw error; + } +} +//SESSION export async function getSessionsOfUserAPI(user:Coach|Athlete){ try { if (user instanceof Coach) { From 92699891309ed79ca8114345557a03a15af0b2d9 Mon Sep 17 00:00:00 2001 From: tuanvu Date: Fri, 9 Jan 2026 15:23:21 +0100 Subject: [PATCH 2/2] getByID --- front_end/src/api.ts | 3 ++- front_end/src/components/test_api.tsx | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/front_end/src/api.ts b/front_end/src/api.ts index 0a57c87..b1a3816 100644 --- a/front_end/src/api.ts +++ b/front_end/src/api.ts @@ -80,7 +80,8 @@ export const coachService = { // controller doesn't declare a class-level path consistently; support both common patterns create: (data: any) => api.post(`/coach/create`, data), getAll: () => api.get(`/coach/all`), - getByKeycloakId: (id: number | string) => api.get(`/coach/${id}`), + getById: (id: number) => api.get(`/coach/${id}`), + getByKeycloakId: (keycloakId: string) => api.get(`/coach/keycloak/${keycloakId}`), 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`), diff --git a/front_end/src/components/test_api.tsx b/front_end/src/components/test_api.tsx index a1c54e2..e4ed6d0 100644 --- a/front_end/src/components/test_api.tsx +++ b/front_end/src/components/test_api.tsx @@ -1,5 +1,5 @@ import { useKeycloak } from "@react-keycloak/web" -import { getAllCoach, getUsersAPI, postAdmin } from "../requetes" +import { getAllCoach } from "../requetes" import { Admin } from "../classes"; @@ -15,7 +15,7 @@ function TestAPI(){ admin.nom = "admin"; admin.email = "admin@gmail.com"; - postAdmin(admin); + //createAdminAPI(admin); } return(