From 42dea977637fbd5a545efee864f49d731a5ab59f Mon Sep 17 00:00:00 2001 From: Arthur Wambst Date: Thu, 16 Oct 2025 03:24:01 +0200 Subject: [PATCH] front --- src/component/Navigation/Navigation.tsx | 2 +- src/pages/Dashboard.tsx | 82 +++++++++++++++++-------- src/pages/Login.tsx | 2 +- src/type/Dashboard.ts | 9 +-- src/type/InstanceType.ts | 2 +- src/type/JiType.ts | 12 ++++ src/type/SujetType.ts | 7 +++ src/type/TpType.ts | 11 ---- 8 files changed, 83 insertions(+), 44 deletions(-) create mode 100644 src/type/JiType.ts create mode 100644 src/type/SujetType.ts delete mode 100644 src/type/TpType.ts diff --git a/src/component/Navigation/Navigation.tsx b/src/component/Navigation/Navigation.tsx index 114416d..6487e90 100644 --- a/src/component/Navigation/Navigation.tsx +++ b/src/component/Navigation/Navigation.tsx @@ -41,7 +41,7 @@ const Navigation: React.FC = ({ }; useEffect(() => { - axios.get("/api/users/me").then((res) => { + axios.get("/api/user/me").then((res) => { if (res.data.username.trim() === "") { navigate("/login"); } diff --git a/src/pages/Dashboard.tsx b/src/pages/Dashboard.tsx index a3839a6..7a9cd86 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/Dashboard.tsx @@ -1,12 +1,13 @@ import { useEffect, useState } from "react"; import axios from "axios"; import { Link } from "react-router-dom"; -import { Tp } from "../type/TpType"; +import { Sujet } from "../type/SujetType"; +import { Ji } from "../type/JiType"; import { DashboardType } from "../type/Dashboard"; function Dashboard() { const [dashboard, setDashboard] = useState(null); - const username = localStorage.getItem("username"); + const username = localStorage.getItem("name"); useEffect(() => { axios.get("/api/dashboard").then((res) => { setDashboard(res.data); @@ -27,60 +28,61 @@ function Dashboard() { {dashboard && ( <> + { dashboard.jiRespo.length !== 0 && (

- Practicals + Immersions - Respo

-
- {dashboard.tps.map((tp: Tp) => ( +
+ {dashboard.jiRespo.map((jiRespo: Ji) => (
-

{tp.name}

-

{tp.description}

+

{jiRespo.name}

+

{jiRespo.description}

- - Learn More + + GO
))}
- {dashboard.tps.length === 0 && ( -

You have no tps

- )} +
+ )} + { dashboard.sujetRespo.length !== 0 && (
-

Instances

+

Sujets - Respo

- {dashboard.instances.map((instance) => ( + {dashboard.sujetRespo.map((sujet: Sujet) => (
-

{instance.name}

- {instance.tp && ( -

Linked to: {instance.tp.name}

+

{sujetRespo.name}

+ {sujetRespo && ( +

Linked to: {sujetRespo.name}

)}
{false && ( Learn More )} - {instance.tp && ( + {sujetRespo && ( See TP @@ -90,13 +92,41 @@ function Dashboard() {
))} - {dashboard.instances.length === 0 && ( -

You have no instances

- )}
-
+ )} +
+
+

+ Immersions - Activites +

+
+ {dashboard.jiParticipant.map((jiParticipant: Ji) => ( +
+
+

{jiParticipant.name}

+

{jiParticipant.description}

+
+ + Learn More + +
+
+
+ ))} +
+ {dashboard.jiParticipant.length === 0 && ( +
+

You are not registered on any activities.

+
+ )} +
+
+

Messages

You have no messages

diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index 276a407..cc79e7c 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -24,7 +24,7 @@ const LoginPage: React.FC = () => { if (response.status === 200) { axios.get("/api/users/me").then((res) => { localStorage.setItem("username", res.data.username); - if (res.data.roles.includes("root")) { + if (res.data.roles.includes("ROOT")) { localStorage.setItem("root", "true"); } else { localStorage.removeItem("root"); diff --git a/src/type/Dashboard.ts b/src/type/Dashboard.ts index 18c3925..2abf5e0 100644 --- a/src/type/Dashboard.ts +++ b/src/type/Dashboard.ts @@ -1,7 +1,8 @@ -import { Instance } from "./InstanceType"; -import { Tp } from "./TpType"; +import { Ji } from "./JiType"; +import { Sujet } from "./SujetType"; export interface DashboardType { - tps: Tp[]; - instances: Instance[]; + jiRespo: Ji[]; + jiParticipant: Ji[]; + sujetRespo: Sujet[]; } diff --git a/src/type/InstanceType.ts b/src/type/InstanceType.ts index 2de6819..9e35263 100644 --- a/src/type/InstanceType.ts +++ b/src/type/InstanceType.ts @@ -1,4 +1,4 @@ -import { Tp } from "./TpType"; +import { Ji } from "./JiType"; import { User } from "./UserType"; export interface Instance { diff --git a/src/type/JiType.ts b/src/type/JiType.ts new file mode 100644 index 0000000..cc9de2c --- /dev/null +++ b/src/type/JiType.ts @@ -0,0 +1,12 @@ +import { Sujet } from "./SujetType"; +import { User } from "./UserType"; + +export interface Ji { + name: string; + description: string; + respos: User[]; + date: string; + site: Site; + participants: User[]; + //instances: Instances[]; +} diff --git a/src/type/SujetType.ts b/src/type/SujetType.ts new file mode 100644 index 0000000..0f404ad --- /dev/null +++ b/src/type/SujetType.ts @@ -0,0 +1,7 @@ +export interface Sujet { + id: number; + name: string; + description: string; + pdfLink: string; + respos: string; +} diff --git a/src/type/TpType.ts b/src/type/TpType.ts deleted file mode 100644 index 568d5f7..0000000 --- a/src/type/TpType.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface Tp { - id: number; - name: string; - description: string; - pdfLink: string; - respo: string; - date: string; - ssh: string; - port: string; - pwd: string; -}