Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
@@ -44,11 +44,11 @@ public class SessionResource {
|
||||
@PreAuthorize("hasRole('coach')")
|
||||
public ResponseEntity<?> create(@RequestBody SessionDTO dto) {
|
||||
try {
|
||||
Session session = maptoEntity(dto);
|
||||
if(sessionDAO.findById(session.getId()).isPresent()) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Session with ID " + session.getId() + " already exists.");
|
||||
if(sessionDAO.findById(dto.getId()).isPresent()) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Session with ID " + dto.getId() + " already exists.");
|
||||
|
||||
}
|
||||
Session session = maptoEntity(dto);
|
||||
Coach c = coachDAO.findById(dto.getCoachId()).orElse(null);
|
||||
session.setCoach(c);
|
||||
sessionDAO.save(session);
|
||||
@@ -161,7 +161,7 @@ public class SessionResource {
|
||||
|
||||
private Session maptoEntity(SessionDTO dto) {
|
||||
Session session = new Session();
|
||||
System.out.println("ID "+ dto.getId());
|
||||
System.out.println("ID "+ session.getId());
|
||||
session.setName(dto.getName());
|
||||
session.setIsRecurrent(dto.getIsRecurrent());
|
||||
session.setCreneau(dto.getCreneau());
|
||||
|
||||
@@ -45,7 +45,7 @@ export const athleteService = {
|
||||
delete: (id: number | string) => api.delete(`/athlete/${id}`),
|
||||
|
||||
// session-related endpoints exposed by AthleteResource
|
||||
getSessionsForAthlete: (athleteId: number | string) => api.get(`/athletes/athlete/${athleteId}/session`),
|
||||
getSessionsForAthlete: (athleteId: number | null) => api.get(`/athletes/athlete/${athleteId}/session`),
|
||||
getAllSessions: () => api.get(`/athletes/session`),
|
||||
getActivitiesForSession: (sessionId: number | string) => api.get(`/athletes/session/${sessionId}/activities`),
|
||||
getSessionsAfterDate: (athleteId: number | string, date: string) => api.get(`/athletes/${athleteId}/session/after/${encodeURIComponent(date)}`),
|
||||
@@ -84,7 +84,7 @@ export const coachService = {
|
||||
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`),
|
||||
getSessionsForCoach: (coachId: number | null) => api.get(`/coach/${coachId}/session`),
|
||||
};
|
||||
|
||||
export const userService = {
|
||||
|
||||
@@ -4,20 +4,21 @@ export type Groupe = "Entrainement" | "Competition" | "Loisir"| "";
|
||||
|
||||
|
||||
export class Ligne{
|
||||
id!: number;
|
||||
id: number|null = null;
|
||||
nom!: string;
|
||||
composition!: Athlete[] //les joueurs compososant la ligne
|
||||
tempsDeJeu!: number; // en minutes
|
||||
}
|
||||
|
||||
export class User{
|
||||
id!: number;
|
||||
id: number|null = null;
|
||||
keycloakId!: string;
|
||||
nom!: string;
|
||||
prenom!:string;
|
||||
email!: string;
|
||||
}
|
||||
|
||||
|
||||
export class Admin extends User{
|
||||
|
||||
constructor(dto:AdminDTO);
|
||||
@@ -25,7 +26,7 @@ export class Admin extends User{
|
||||
|
||||
constructor(dto?:AdminDTO){
|
||||
super();
|
||||
this.id = dto?.id ?? 0;
|
||||
this.id = dto?.id ?? null;
|
||||
this.keycloakId = dto?.id_keycloak ?? "";
|
||||
this.nom = dto?.name ?? "";
|
||||
this.prenom = dto?.prenom ?? "";
|
||||
@@ -113,7 +114,7 @@ export class Coach extends User{
|
||||
}
|
||||
|
||||
export class Session{
|
||||
id!: number;
|
||||
id: number|null = null;
|
||||
name!: string;
|
||||
activitesID: number[] = [];
|
||||
activites: Activite[] = [];
|
||||
@@ -147,7 +148,7 @@ export class Session{
|
||||
|
||||
toDTO():SessionDTO{
|
||||
const dto:SessionDTO = {
|
||||
id: 0,
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
isRecurrent: this.isRecurrent,
|
||||
creneau: this.creneau.toISOString(),
|
||||
@@ -162,7 +163,7 @@ export class Session{
|
||||
}
|
||||
|
||||
export class Activite{
|
||||
id!: number;
|
||||
id: number|null = null;
|
||||
nom!: string;
|
||||
session!: Session;
|
||||
theme!: string;
|
||||
@@ -184,7 +185,7 @@ export class Activite{
|
||||
|
||||
toDTO():ActiviteDTO{
|
||||
const dto:ActiviteDTO = {
|
||||
id: 0,
|
||||
id: this.id,
|
||||
name: this.nom,
|
||||
duree: this.duree,
|
||||
dataActivite: [],
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { Groupe } from "./classes";
|
||||
|
||||
export type ActiviteDTO = {
|
||||
id: number;
|
||||
id: number|null;
|
||||
name: string;
|
||||
theme: string;
|
||||
duree: number;
|
||||
dataActivite: string[];
|
||||
sessionId: number;
|
||||
sessionId: number|null;
|
||||
}
|
||||
|
||||
export type AdminDTO = {
|
||||
id: number;
|
||||
id: number|null;
|
||||
id_keycloak: string;
|
||||
name: string;
|
||||
prenom: string;
|
||||
}
|
||||
|
||||
export type AthleteDTO = {
|
||||
id:number;
|
||||
id:number|null;
|
||||
id_keycloak: string;
|
||||
name: string;
|
||||
prenom: string;
|
||||
@@ -28,7 +28,7 @@ export type AthleteDTO = {
|
||||
};
|
||||
|
||||
export type CoachDTO = {
|
||||
id: number;
|
||||
id: number|null;
|
||||
id_keycloak: string;
|
||||
name: string;
|
||||
prenom: string;
|
||||
@@ -36,14 +36,14 @@ export type CoachDTO = {
|
||||
};
|
||||
|
||||
export type SessionDTO = {
|
||||
id: number;
|
||||
id: number|null;
|
||||
name: string;
|
||||
isRecurrent: boolean;
|
||||
creneau: string; // LocalDateTime → ISO string
|
||||
duree: number;
|
||||
groupe: Groupe;
|
||||
|
||||
coachId: number;
|
||||
coachId: number|null;
|
||||
athleteIds: number[];
|
||||
activiteIds: number[];
|
||||
};
|
||||
|
||||
@@ -145,7 +145,7 @@ function LigneList({ lignes, tempsDeJeuParLigne }: LigneListProps) {
|
||||
</div>
|
||||
<div>
|
||||
<strong>Temps de jeu total :</strong>{" "}
|
||||
{tempsDeJeuParLigne.get(lignes.id) ?? 0} min
|
||||
{/* {tempsDeJeuParLigne.get(lignes.id) ?? 0} min */}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -210,10 +210,14 @@ export async function getAllUserAPI(): Promise<User[]> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getCoachByIdAPI(id:number): Promise<Coach|null> {
|
||||
export async function getCoachByIdAPI(id:number|null): Promise<Coach|null> {
|
||||
try{
|
||||
if(id!==null){
|
||||
const response = await coachService.getById(id);
|
||||
return new Coach(response.data);
|
||||
}
|
||||
console.error("Error fetching coach by id : id null");
|
||||
return null;
|
||||
}catch (error) {
|
||||
console.error("Error fetching coach by id:", error);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user