Merge branch 'main' of https://gitlab2.istic.univ-rennes1.fr/tuvu/hackathon
This commit is contained in:
@@ -54,7 +54,7 @@ public class SessionResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasRole('coach') or hasRole('athlete')")
|
@PreAuthorize("hasRole('admin') or hasRole('coach') or hasRole('athlete')")
|
||||||
public ResponseEntity<List<SessionDTO>> getAll() {
|
public ResponseEntity<List<SessionDTO>> getAll() {
|
||||||
List<Session> sessions = sessionDAO.findAll();
|
List<Session> sessions = sessionDAO.findAll();
|
||||||
List<SessionDTO> dtos = new ArrayList<>();
|
List<SessionDTO> dtos = new ArrayList<>();
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ 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(`/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),
|
update: (id: number | string, data: any) => api.put(`/coach/update/${id}`, data),
|
||||||
delete: (id: number | string) => api.delete(`/coach/delete/${id}`),
|
delete: (id: number | string) => api.delete(`/coach/delete/${id}`),
|
||||||
getSessionsForCoach: (coachId: number | string) => api.get(`/coach/${coachId}/session`),
|
getSessionsForCoach: (coachId: number | string) => api.get(`/coach/${coachId}/session`),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { useKeycloak } from "@react-keycloak/web";
|
|||||||
const[allCoachs,setAllCoachs] = useState<Coach[]>([]);
|
const[allCoachs,setAllCoachs] = useState<Coach[]>([]);
|
||||||
const[allSessions,setAllSessions] = useState<Session[]>([]);
|
const[allSessions,setAllSessions] = useState<Session[]>([]);
|
||||||
const[allLignes,setAllLignes] = useState<Ligne[]>([]);
|
const[allLignes,setAllLignes] = useState<Ligne[]>([]);
|
||||||
|
const[allActivites,setAllActivites] = useState<Activite[]>([]);
|
||||||
|
|
||||||
|
|
||||||
async function updateAthletes() {
|
async function updateAthletes() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useKeycloak } from "@react-keycloak/web"
|
import { useKeycloak } from "@react-keycloak/web"
|
||||||
import { getAllCoach, getUsersAPI, postAdmin } from "../requetes"
|
import { getAllCoach } from "../requetes"
|
||||||
import { Admin } from "../classes";
|
import { Admin } from "../classes";
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ function TestAPI(){
|
|||||||
admin.nom = "admin";
|
admin.nom = "admin";
|
||||||
admin.email = "admin@gmail.com";
|
admin.email = "admin@gmail.com";
|
||||||
|
|
||||||
postAdmin(admin);
|
//createAdminAPI(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ export async function updateActivitiesOfSessionAPI(session:Session,activities:Ac
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching activities for session:", error);
|
console.error("Error fetching activities for session:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function subscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
export async function subscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
||||||
@@ -105,11 +104,7 @@ export async function unsubscribeSessionAPI(user:User, session:Session):Promise<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADMIN :
|
|
||||||
|
|
||||||
export async function updateAllUserAPI(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST /////////////////////////////////////////////////////////
|
// POST /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -125,7 +120,8 @@ export async function createSessionAPI(session: Session): Promise<Session> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postActivityAPI(session: Session, activity: Activite){
|
|
||||||
|
export async function createActivityAPI(session: Session, activity: Activite){
|
||||||
try {
|
try {
|
||||||
const response = await api.post<Activite>(`/session/${session.id}/activities`, activity);
|
const response = await api.post<Activite>(`/session/${session.id}/activities`, activity);
|
||||||
return response.data;
|
return response.data;
|
||||||
@@ -178,7 +174,8 @@ export async function postSession(session: Session){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postAdmin(athlete: Admin):Promise<Admin>{
|
// SET /////////////////////////////////////////////////////////
|
||||||
|
export async function createAdminAPI(athlete: Admin):Promise<Admin>{
|
||||||
try {
|
try {
|
||||||
const response = await api.post<Admin>("/admin/create/",athlete);
|
const response = await api.post<Admin>("/admin/create/",athlete);
|
||||||
console.log(response);
|
console.log(response);
|
||||||
@@ -189,22 +186,20 @@ export async function postAdmin(athlete: Admin):Promise<Admin>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SET /////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//ADMIN
|
|
||||||
export async function setUserNameAPI(user: User, name: string){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//COACH
|
|
||||||
export async function setSessionCreneauAPI(session: Session, date:Date){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//GET /////////////////////////////////////////////////////////
|
//GET /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//SESSION
|
//USER
|
||||||
|
export async function getAllUserAPI(): Promise<User[]> {
|
||||||
|
try{
|
||||||
|
const response = await api.get<User[]>("/users/all");
|
||||||
|
return response.data;
|
||||||
|
}catch (error) {
|
||||||
|
console.error("Error fetching users:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//SESSION
|
||||||
export async function getSessionsOfUserAPI(user:Coach|Athlete){
|
export async function getSessionsOfUserAPI(user:Coach|Athlete){
|
||||||
try {
|
try {
|
||||||
if (user instanceof Coach) {
|
if (user instanceof Coach) {
|
||||||
|
|||||||
Reference in New Issue
Block a user