From abbf4cb726d471d5f45ecfaf9911f1997a8eff7f Mon Sep 17 00:00:00 2001 From: trochas Date: Wed, 7 Jan 2026 13:50:50 +0100 Subject: [PATCH 1/3] debug api --- front_end/src/api.ts | 1 + front_end/src/components/test_api.tsx | 7 +- front_end/src/requetes.tsx | 19 +++--- package-lock.json | 94 +-------------------------- 4 files changed, 17 insertions(+), 104 deletions(-) diff --git a/front_end/src/api.ts b/front_end/src/api.ts index e6cd610..aea29ba 100644 --- a/front_end/src/api.ts +++ b/front_end/src/api.ts @@ -12,6 +12,7 @@ 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; }); diff --git a/front_end/src/components/test_api.tsx b/front_end/src/components/test_api.tsx index 1e39c09..2fd52e7 100644 --- a/front_end/src/components/test_api.tsx +++ b/front_end/src/components/test_api.tsx @@ -1,9 +1,12 @@ -import { getUsersAPI } from "../requetes" +import { useKeycloak } from "@react-keycloak/web" +import { getCoachsAPI, getUsersAPI } from "../requetes" + function TestAPI(){ + const { keycloak } = useKeycloak() function handleGetUsers(): void { - getUsersAPI() + getCoachsAPI(); } return( diff --git a/front_end/src/requetes.tsx b/front_end/src/requetes.tsx index 626a244..30a1b83 100644 --- a/front_end/src/requetes.tsx +++ b/front_end/src/requetes.tsx @@ -1,14 +1,5 @@ import api from "./api"; import { Activite, Athlete, Coach, Session, User } from "./classes"; -//import { useKeycloak } from '@react-keycloak/web' - -//const { keycloak } = useKeycloak() -/* -const useAuthHeader = () => { - return keycloak?.token - ? { Authorization: `Bearer ${keycloak.token}` } - : {} -}*/ //debug: export function delay(ms: number): Promise { @@ -146,4 +137,14 @@ export async function getUsersAPI(): Promise { console.error("Error fetching users:", error); throw error; } +} + +export async function getCoachsAPI(): Promise { + try { + const response = await api.get("/coach/all"); + return response.data; + } catch (error) { + console.error("Error fetching coachs:", error); + throw error; + } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0b5f782..89b9cd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,97 +2,5 @@ "name": "hackathon", "lockfileVersion": 3, "requires": true, - "packages": { - "": { - "dependencies": { - "react-router-dom": "^7.11.0" - } - }, - "node_modules/cookie": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", - "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/react": { - "version": "19.2.3", - "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", - "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react-dom": { - "version": "19.2.3", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", - "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", - "license": "MIT", - "peer": true, - "dependencies": { - "scheduler": "^0.27.0" - }, - "peerDependencies": { - "react": "^19.2.3" - } - }, - "node_modules/react-router": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.11.0.tgz", - "integrity": "sha512-uI4JkMmjbWCZc01WVP2cH7ZfSzH91JAZUDd7/nIprDgWxBV1TkkmLToFh7EbMTcMak8URFRa2YoBL/W8GWnCTQ==", - "license": "MIT", - "dependencies": { - "cookie": "^1.0.1", - "set-cookie-parser": "^2.6.0" - }, - "engines": { - "node": ">=20.0.0" - }, - "peerDependencies": { - "react": ">=18", - "react-dom": ">=18" - }, - "peerDependenciesMeta": { - "react-dom": { - "optional": true - } - } - }, - "node_modules/react-router-dom": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.11.0.tgz", - "integrity": "sha512-e49Ir/kMGRzFOOrYQBdoitq3ULigw4lKbAyKusnvtDu2t4dBX4AGYPrzNvorXmVuOyeakai6FUPW5MmibvVG8g==", - "license": "MIT", - "dependencies": { - "react-router": "7.11.0" - }, - "engines": { - "node": ">=20.0.0" - }, - "peerDependencies": { - "react": ">=18", - "react-dom": ">=18" - } - }, - "node_modules/scheduler": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", - "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", - "license": "MIT" - }, - "node_modules/set-cookie-parser": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz", - "integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==", - "license": "MIT" - } - } + "packages": {} } From cd4fb99429071ab9489d6e80013064118f4c6e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ama=C3=ABl=20Kesteman?= Date: Wed, 7 Jan 2026 17:57:18 +0100 Subject: [PATCH 2/3] Feat: Ajout de la classe ligne pour la partie 2. --- front_end/src/classes.tsx | 69 ++++-- front_end/src/components/ressourceList.tsx | 37 ++- front_end/src/components/ressourcePanel.tsx | 240 ++++++++++++-------- 3 files changed, 225 insertions(+), 121 deletions(-) diff --git a/front_end/src/classes.tsx b/front_end/src/classes.tsx index 739e1cf..d4c6dd9 100644 --- a/front_end/src/classes.tsx +++ b/front_end/src/classes.tsx @@ -8,6 +8,13 @@ export class User{ role!: Role; } +export class Ligne{ + id!: number; + nom!: String; + composition!: Athlete[] //les joueurs compososant la ligne + tempsDeJeu!: number; // en minutes +} + export class Admin extends User{ role!: Role; @@ -37,6 +44,7 @@ export class Session{ athletes!: Athlete[] duree! : number; groupe! : Groupe; + ligne! : Ligne[]; } export class Activite{ @@ -54,24 +62,6 @@ export function getUserTest():User{ const s1 = new Session(); const s2 = new Session(); const s3 = new Session(); - user.id = 0; - user.nom = "Emilien-Yee NootNoot"; - user.role = "Coach" - s1.creneau = new Date(); - s1.id = 1; - s1.name = "Entrainement Frisbee" - s1.isRecurrent = true; - var date2 = new Date(); - date2.setDate(date2.getDate() + 2); - s2.creneau = date2; - s2.id = 2; - s2.isRecurrent = false; - s2.name = "entraintement 2" - s3.creneau = date2; - s3.id = 3; - s3.isRecurrent = false; - s3.name = "entraintement 3" - const athlete1 = new Athlete(); athlete1.id = 1; athlete1.nom = "Alice Dupont"; @@ -87,6 +77,49 @@ export function getUserTest():User{ athlete3.nom = "Clara Lopez"; athlete3.groupe = "Loisir"; + const ligne1 = new Ligne(); + ligne1.id = 1; + ligne1.nom = "Ligne A"; + ligne1.composition = [athlete1, athlete2]; // Alice + Bob + ligne1.tempsDeJeu = 45; + + const ligne2 = new Ligne(); + ligne2.id = 2; + ligne2.nom = "Ligne B"; + ligne2.composition = [athlete2, athlete3]; // Bob + Clara + ligne2.tempsDeJeu = 40; + + const ligne3 = new Ligne(); + ligne3.id = 3; + ligne3.nom = "Ligne C"; + ligne3.composition = [athlete1, athlete3]; // Alice + Clara + ligne3.tempsDeJeu = 50; + + + + user.id = 0; + user.nom = "Emilien-Yee NootNoot"; + user.role = "Coach" + s1.creneau = new Date(); + s1.id = 1; + s1.name = "Entrainement Frisbee" + s1.isRecurrent = true; + s1.ligne = [ligne1]; + var date2 = new Date(); + date2.setDate(date2.getDate() + 2); + s2.creneau = date2; + s2.id = 2; + s2.isRecurrent = false; + s2.name = "entraintement 2" + s2.ligne = [ligne2]; + s3.creneau = date2; + s3.id = 3; + s3.isRecurrent = false; + s3.name = "entraintement 3" + s3.ligne = [ligne3]; + + + s1.athletes = [athlete1, athlete2]; s2.athletes = [athlete2, athlete3]; s3.athletes = [athlete1, athlete3]; diff --git a/front_end/src/components/ressourceList.tsx b/front_end/src/components/ressourceList.tsx index c597865..b21912a 100644 --- a/front_end/src/components/ressourceList.tsx +++ b/front_end/src/components/ressourceList.tsx @@ -1,9 +1,10 @@ -import { Athlete, Activite, Coach, Session } from "../classes"; +import { Athlete, Activite, Coach, Session, Ligne } from "../classes"; type AthleteListProps = { athletes: Athlete[] }; type ActiviteListProps = { activites: Activite[] }; type CoachListProps = { coachs: Coach[] }; type SessionListProps = { sessions: Session[]}; +type LigneListProps = { lignes: Ligne[]}; function AthleteList({ athletes }: AthleteListProps) { return ( @@ -70,6 +71,9 @@ function SessionList({ sessions }: SessionListProps) {
Coach: {sessions.coach ? sessions.coach.nom : "Pas de coach sur la séance"}
+
+ Ligne: {sessions.ligne ? sessions.ligne.map(ligne => ligne.nom).join(", ") : "Pas de ligne sur la séance"} +
))} @@ -77,4 +81,33 @@ function SessionList({ sessions }: SessionListProps) { ); } -export { AthleteList, ActiviteList, CoachList , SessionList }; \ No newline at end of file +function LigneList({ lignes }: LigneListProps) { + return ( +
    + {lignes.map((lignes) => ( +
  • +
    + Nom: {lignes.nom} +
    +
    +
    + Composition : +
      + {lignes.composition.map((athlete) => ( +
    • + {athlete.nom} +
    • + ))} +
    +
    +
    +
    + Temps de jeu: {lignes.tempsDeJeu} +
    +
  • + ))} +
+ ); +} + +export { AthleteList, ActiviteList, CoachList , SessionList, LigneList }; \ No newline at end of file diff --git a/front_end/src/components/ressourcePanel.tsx b/front_end/src/components/ressourcePanel.tsx index b46469e..57f8661 100644 --- a/front_end/src/components/ressourcePanel.tsx +++ b/front_end/src/components/ressourcePanel.tsx @@ -1,125 +1,163 @@ -import { useState } from "react"; -import { useLocalData } from "../context/useLocalData"; -import { AthleteList, ActiviteList, CoachList, SessionList} from "./ressourceList"; -import { Activite, Athlete, Coach , Session } from "../classes"; + import { useState } from "react"; + import { useLocalData } from "../context/useLocalData"; + import { AthleteList, ActiviteList, CoachList, SessionList, LigneList} from "./ressourceList"; + import { Activite, Athlete, Coach , Session, Ligne } from "../classes"; -export default function RessourcePanel() { - const { user } = useLocalData(); - const [showAthletes, setShowAthletes] = useState(false); - const [showActivites, setShowActivites] = useState(false); - const [showCoachs,setShowCoachs] = useState(false); - const [showSessions, setShowSessions] = useState(false); - console.log("Rôle utilisateur:", user.role); - if (user.role === "Athlete") return null; + export default function RessourcePanel() { + const { user } = useLocalData(); + const [showAthletes, setShowAthletes] = useState(false); + const [showActivites, setShowActivites] = useState(false); + const [showCoachs,setShowCoachs] = useState(false); + const [showSessions, setShowSessions] = useState(false); + const [showLignes, setShowLignes] = useState(false); + console.log("Rôle utilisateur:", user.role); + if (user.role === "Athlete") return null; - const athleteMap: Map = new Map(); - user.sessions.forEach(session => { - session.athletes?.forEach(a => athleteMap.set(a.id, a)); - }); - const allAthletes: Athlete[] = Array.from(athleteMap.values()); + const athleteMap: Map = new Map(); + user.sessions.forEach(session => { + session.athletes?.forEach(a => athleteMap.set(a.id, a)); + }); + const allAthletes: Athlete[] = Array.from(athleteMap.values()); - const activiteMap: Map = new Map(); - user.sessions.forEach(session => { - session.activites?.forEach(act => activiteMap.set(act.id, act)); - }); - const allActivites: Activite[] = Array.from(activiteMap.values()); + const activiteMap: Map = new Map(); + user.sessions.forEach(session => { + session.activites?.forEach(act => activiteMap.set(act.id, act)); + }); + const allActivites: Activite[] = Array.from(activiteMap.values()); - const coachMap: Map = new Map(); - user.sessions.forEach(session => { - if (session.coach) { - coachMap.set(session.coach.id, session.coach); - } - }); + const coachMap: Map = new Map(); + user.sessions.forEach(session => { + if (session.coach) { + coachMap.set(session.coach.id, session.coach); + } + }); - const allCoachs: Coach[] = Array.from(coachMap.values()); + const allCoachs: Coach[] = Array.from(coachMap.values()); - const sessionMap: Map = new Map(); - user.sessions.forEach(session => { - sessionMap.set(session.id, session); - }); + const sessionMap: Map = new Map(); + user.sessions.forEach(session => { + sessionMap.set(session.id, session); + }); - const allSessions: Session[] = Array.from(sessionMap.values()); + const allSessions: Session[] = Array.from(sessionMap.values()); - function onAthletesClick(): void { - setShowAthletes(prev => !prev); - setShowActivites(false); - setShowCoachs(false); - setShowSessions(false); + const ligneMap: Map = new Map(); + user.sessions.forEach(session => { + if (session.ligne) { - } - function onActivitiesClick(): void { - setShowActivites(prev => !prev); - setShowAthletes(false); - setShowCoachs(false); - setShowSessions(false); + session.ligne.forEach(ligne => { + ligneMap.set(ligne.id, ligne); + }); + } + }); + + const allLignes: Ligne[] = Array.from(ligneMap.values()); + + function onAthletesClick(): void { + setShowAthletes(prev => !prev); + setShowActivites(false); + setShowCoachs(false); + setShowSessions(false); + setShowLignes(false); + + } + function onActivitiesClick(): void { + setShowActivites(prev => !prev); + setShowAthletes(false); + setShowCoachs(false); + setShowSessions(false); + setShowLignes(false); - } - function onCoachClick(): void { - setShowCoachs(prev => !prev); - setShowActivites(false); - setShowAthletes(false); - setShowSessions(false); + } + function onCoachClick(): void { + setShowCoachs(prev => !prev); + setShowActivites(false); + setShowAthletes(false); + setShowSessions(false); + setShowLignes(false); - } + } - function onSessionClick(): void { - setShowSessions(prev => !prev); - setShowActivites(false); - setShowAthletes(false); - setShowCoachs(false); + function onSessionClick(): void { + setShowSessions(prev => !prev); + setShowActivites(false); + setShowAthletes(false); + setShowCoachs(false); + setShowLignes(false); - } + } + + function onLigneClick():void{ + setShowLignes(prev => !prev); + setShowAthletes(false); + setShowActivites(false); + setShowCoachs(false); + setShowSessions(false); + } - return ( -
- + return ( +
+
+ Sélectionner une ressource: +
+ - {showActivites && ( -
-

Liste des activités

- -
- )} + {showAthletes && ( +
+

Liste des athlètes

+ +
+ )} - {showCoachs && ( -
-

Liste des coachs

- -
- )} + {showActivites && ( +
+

Liste des activités

+ +
+ )} - {showSessions && ( -
-

Liste des sessions

- -
- )} + {showCoachs && ( +
+

Liste des coachs

+ +
+ )} + + {showSessions && ( +
+

Liste des sessions

+ +
+ )} + + {showLignes && ( +
+

Liste des lignes

+ +
+ )} -
- ); -} +
+ ); + } From 153035cefa3f3c4f7b22f881d50ff9a281b4a002 Mon Sep 17 00:00:00 2001 From: trochas Date: Wed, 7 Jan 2026 18:00:39 +0100 Subject: [PATCH 3/3] =?UTF-8?q?ajout=20d'activit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front_end/src/classes.tsx | 1 + front_end/src/components/createActivite.tsx | 75 +++++++++++++++++++++ front_end/src/components/edt.tsx | 5 +- front_end/src/components/edt_session.tsx | 43 +++++++++--- front_end/src/components/login.tsx | 13 +++- front_end/src/components/style/edt.css | 7 ++ front_end/src/components/test_api.tsx | 12 +++- front_end/src/index.css | 7 ++ front_end/src/requetes.tsx | 29 ++++++-- 9 files changed, 171 insertions(+), 21 deletions(-) create mode 100644 front_end/src/components/createActivite.tsx diff --git a/front_end/src/classes.tsx b/front_end/src/classes.tsx index 4021ee2..017757e 100644 --- a/front_end/src/classes.tsx +++ b/front_end/src/classes.tsx @@ -4,6 +4,7 @@ export class User{ id!: number; nom!: String; sessions: Session[] = []; //nb: Admin liaison non symétrique /!\ + email!: String; } export class Admin extends User{ diff --git a/front_end/src/components/createActivite.tsx b/front_end/src/components/createActivite.tsx new file mode 100644 index 0000000..9a7b886 --- /dev/null +++ b/front_end/src/components/createActivite.tsx @@ -0,0 +1,75 @@ +import { useState, useEffect } from "react"; +import { Session, User, Coach, Activite, Groupe } from "../classes"; +import { Modal } from "./Modal"; + +type CreateActiciteProps = { + returnActivite: (activite:Activite|null) => void +} + + +export function CreateActivite({ returnActivite }: CreateActiciteProps){ + + const [activities, setActivities] = useState([]); + const [activiteNom, setActiviteNom] = useState(""); + const [activiteTheme, setActiviteTheme] = useState(""); + const [activiteDuree, setActiviteDuree] = useState(0); + + function addAcitivte(){ + if (!activiteNom) return; + + const newActivite = new Activite(); + newActivite.nom= activiteNom; + newActivite.theme=activiteTheme; + newActivite.duree= activiteDuree; + newActivite.data= new Map(); + setActivities([...activities, newActivite]); + + setActiviteNom(""); + setActiviteTheme(""); + setActiviteDuree(0); + + returnActivite(newActivite); + } + + function cancel(){ + returnActivite(null); + } + + + + return ( + cancel()}> +
+

Nouvelle Activité :

+
+ Nom de l'activité: +
+
+ setActiviteNom(e.target.value)} /> +
+
+ Theme: +
+
+ setActiviteTheme(e.target.value)} /> +
+
+ Duree (minutes): +
+
+ setActiviteDuree(Number(e.target.value))} /> +
+ + + +
    + {activities.map((act, idx) => ( +
  • {act.nom} - {act.theme} ({act.duree} min)
  • + ))} +
+
+
+ ); +}; + +export default CreateActivite; \ No newline at end of file diff --git a/front_end/src/components/edt.tsx b/front_end/src/components/edt.tsx index e429ae9..df491dd 100644 --- a/front_end/src/components/edt.tsx +++ b/front_end/src/components/edt.tsx @@ -42,10 +42,7 @@ export const EDT =() =>{ var newWeek: Session[] = [] user.sessions.forEach(session => { - if( session.isRecurrent ){ - newWeek.push(session); - } - if(session.creneau >= date && session.creneau <= maxDate && !session.isRecurrent){ + if((session.creneau >= date && session.creneau <= maxDate && !session.isRecurrent) || session.isRecurrent){ newWeek.push(session); } }); diff --git a/front_end/src/components/edt_session.tsx b/front_end/src/components/edt_session.tsx index 48e34db..929b01c 100644 --- a/front_end/src/components/edt_session.tsx +++ b/front_end/src/components/edt_session.tsx @@ -5,6 +5,7 @@ import './style/edt.css'; import { Modal } from './Modal'; import Loading from './loading'; import {delay} from "../requetes"; +import CreateActivite from './createActivite'; type Props = { @@ -13,21 +14,22 @@ type Props = { function EdtSession({session}:Props){ - const [open, setOpen] = useState(false) + const [open, setOpen] = useState(false); + const [open2, setOpen2] = useState(false); const [loading,setLoading] = useState(false); + const [activites,setActivites] = useState([]); function handleOpen(): void { setOpen(!open); } - function handleDeleteActivite(): void { - session.activites.pop(); //TODO + function handleDeleteActivite(activite:Activite): void { + session.activites.splice(session.activites.indexOf(activite), 1); + setActivites([...session.activites]) } function handleAddActivite(): void { - const newActivite = new Activite(); - //TODO - session.activites.push(newActivite); + setOpen2(true) } async function updateActivites(){ @@ -45,13 +47,30 @@ function EdtSession({session}:Props){ } },[open]) + useEffect(() => { + if(!loading){ + setActivites([...session.activites]) + } + },[loading]) + const sDate = session.creneau; + + + + function returnActivite(activite: Activite|null){ + if(activite!==null){ + session.activites.push(activite); + setActivites([...session.activites]) + } + setOpen2(false); + } + return(
handleOpen()}>
{hoursToString(sDate)}
- {!session.isRecurrent &&
recurrent
} + {session.isRecurrent &&
recurrent
}
{session.name}
@@ -64,16 +83,20 @@ function EdtSession({session}:Props){
Activités :
- {session.activites.map((activite,index)=>( + {activites.map((activite,index)=>(
{activite.nom} - +
))} - + {loading &&
}
+ + {open2 && + returnActivite(activite)}/> + }
} diff --git a/front_end/src/components/login.tsx b/front_end/src/components/login.tsx index 3a8d05a..97b4465 100644 --- a/front_end/src/components/login.tsx +++ b/front_end/src/components/login.tsx @@ -29,8 +29,19 @@ export const Login =() =>{ return(
- Authenticated : {keycloak.authenticated ? 'oui' : 'non'} + Etat : {keycloak.authenticated ? 'connecté' : 'non connecté'}
+ {keycloak.authenticated && +
+
+ Keycloak ID : { keycloak.tokenParsed?.sub} +
+
+ User nom : { user.nom} +
+ +
+ } diff --git a/front_end/src/components/style/edt.css b/front_end/src/components/style/edt.css index 0f6b70d..ece465b 100644 --- a/front_end/src/components/style/edt.css +++ b/front_end/src/components/style/edt.css @@ -118,4 +118,11 @@ .addButton{ background-color: var(--tint5); border-radius: 10px; +} + +.edt_activite_modal{ + background-color: var(--tint3); + padding: 10px; + border-radius: 20px; + position: relative; } \ No newline at end of file diff --git a/front_end/src/components/test_api.tsx b/front_end/src/components/test_api.tsx index 2fd52e7..bf40bb6 100644 --- a/front_end/src/components/test_api.tsx +++ b/front_end/src/components/test_api.tsx @@ -1,5 +1,6 @@ import { useKeycloak } from "@react-keycloak/web" -import { getCoachsAPI, getUsersAPI } from "../requetes" +import { getCoachsAPI, getUsersAPI, postAdmin } from "../requetes" +import { Admin } from "../classes"; function TestAPI(){ @@ -9,9 +10,18 @@ function TestAPI(){ getCoachsAPI(); } + function handleSendAdmin(): void { + const admin = new Admin; + admin.nom = "admin"; + admin.email = "admin@gmail.com"; + + postAdmin(admin); + } + return(
+
) } diff --git a/front_end/src/index.css b/front_end/src/index.css index bbb1bfe..414bda6 100644 --- a/front_end/src/index.css +++ b/front_end/src/index.css @@ -64,4 +64,11 @@ code { to { transform: rotate(360deg); } +} + +input{ + background-color: var(--tint2); + color: var(--test); + border-color: var(--tint5); + border-radius: 8px; } \ No newline at end of file diff --git a/front_end/src/requetes.tsx b/front_end/src/requetes.tsx index 06019d1..fb1bc0e 100644 --- a/front_end/src/requetes.tsx +++ b/front_end/src/requetes.tsx @@ -1,5 +1,5 @@ import api from "./api"; -import { Activite, Athlete, Coach, Session, User } from "./classes"; +import { Activite, Admin, Athlete, Coach, Session, User } from "./classes"; //debug: export function delay(ms: number): Promise { @@ -53,7 +53,7 @@ export async function updateActivitiesOfSessionAPI(session:Session){ export async function subscribeSessionAPI(user:User, session:Session):Promise{ try { - await api.post(`/sessions/${session.id}/subscribe`, { userId: user.id }); + await api.post(`/sessions/${session.id}/subscribe`); return true; } catch (error) { console.error("Error subscribing to session:", error); @@ -63,7 +63,7 @@ export async function subscribeSessionAPI(user:User, session:Session):Promise{ try { - await api.post(`/session/${session.id}/unsubscribe`, { userId: user.id }); + await api.post(`/session/${session.id}/unsubscribe`); return true; } catch (error) { console.error("Error unsubscribing from session:", error); @@ -104,8 +104,26 @@ export async function postActivityAPI(session: Session, activity: Activite){ } } -export async function postUser(user: User):Promise{ - return true; +export async function postAthlete(athlete: Athlete):Promise{ + try { + const response = await api.post("/athlete/create/",athlete); + console.log(response); + return response.data; + } catch (error) { + console.error("Error fetching coachs:", error); + throw error; + } +} + +export async function postAdmin(athlete: Admin):Promise{ + try { + const response = await api.post("/admin/create/",athlete); + console.log(response); + return response.data; + } catch (error) { + console.error("Error fetching coachs:", error); + throw error; + } } // SET ///////////////////////////////////////////////////////// @@ -142,6 +160,7 @@ export async function getUsersAPI(): Promise { export async function getCoachsAPI(): Promise { try { const response = await api.get("/coach/all"); + console.log(response); return response.data; } catch (error) { console.error("Error fetching coachs:", error);