diff --git a/front/MyINPulse-front/src/components/canvas/CanvasItem.vue b/front/MyINPulse-front/src/components/canvas/CanvasItem.vue
index 6baa376..6d09c7c 100755
--- a/front/MyINPulse-front/src/components/canvas/CanvasItem.vue
+++ b/front/MyINPulse-front/src/components/canvas/CanvasItem.vue
@@ -95,7 +95,7 @@ const props = defineProps<{
title: number;
titleText: string;
description: string;
- isAdmin: number;
+ isAdmin: boolean;
}>();
const IS_MOCK_MODE = false;
@@ -107,18 +107,23 @@ const editedDescriptions = ref([]);
const isEditing = ref([]);
function getCurrentFormattedDate(): string {
- const now = new Date();
- const year = now.getFullYear();
- const month = String(now.getMonth() + 1).padStart(2, '0'); // +1 car janvier = 0
- const day = String(now.getDate()).padStart(2, '0');
- const hours = String(now.getHours()).padStart(2, '0');
- const minutes = String(now.getMinutes()).padStart(2, '0');
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, "0"); // +1 car janvier = 0
+ const day = String(now.getDate()).padStart(2, "0");
+ const hours = String(now.getHours()).padStart(2, "0");
+ const minutes = String(now.getMinutes()).padStart(2, "0");
- return `${year}-${month}-${day} ${hours}:${minutes}`;
+ return `${year}-${month}-${day} ${hours}:${minutes}`;
}
onMounted(() => {
- fetchData(props.projectId, props.title, getCurrentFormattedDate(), IS_MOCK_MODE);
+ fetchData(
+ props.projectId,
+ props.title,
+ getCurrentFormattedDate(),
+ IS_MOCK_MODE
+ );
});
// Fonctions
@@ -137,10 +142,14 @@ const saveEdit = (index: number) => {
editedDescriptions.value[index].contentSectionCell;
isEditing.value[index] = false;
- if (!IS_MOCK_MODE){
- addSectionCell(currentDescriptions.value[index],
+ if (!IS_MOCK_MODE) {
+ addSectionCell(
+ currentDescriptions.value[index],
(response) => {
- console.log("Modification enregistrée avec succès :", response.data);
+ console.log(
+ "Modification enregistrée avec succès :",
+ response.data
+ );
},
(error) => {
console.error("Erreur lors de l'enregistrement :", error);
@@ -149,7 +158,6 @@ const saveEdit = (index: number) => {
}
};
-
const handleClick = () => {
if (expanded.value) {
const editingInProgress = isEditing.value.some((edit) => edit);
@@ -165,11 +173,13 @@ const handleClick = () => {
const handleFetchSuccess = (sectionCells: SectionCell[]) => {
currentDescriptions.value = sectionCells;
editedDescriptions.value = sectionCells.map(
- (cell) => new SectionCell({
- idSectionCell: cell.idSectionCell,
- sectionId: cell.sectionId,
- contentSectionCell: cell.contentSectionCell,
- modificationDate: cell.modificationDate, })
+ (cell) =>
+ new SectionCell({
+ idSectionCell: cell.idSectionCell,
+ sectionId: cell.sectionId,
+ contentSectionCell: cell.contentSectionCell,
+ modificationDate: cell.modificationDate,
+ })
);
isEditing.value = Array(sectionCells.length).fill(false);
};
@@ -178,28 +188,43 @@ const handleFetchError = (error: unknown) => {
console.error("Erreur lors de la récupération des données :", error);
};
-const fetchData = async ( projectId: number, title: number, date: string, useMock = false ) => {
+const fetchData = async (
+ projectId: number,
+ title: number,
+ date: string,
+ useMock = false
+) => {
try {
if (useMock) {
const responseData = await mockFetch(projectId, title, date);
handleFetchSuccess(responseData);
} else {
await new Promise((resolve, reject) => {
- getSectionCellsByDate( projectId, title, date,
+ getSectionCellsByDate(
+ projectId,
+ title,
+ date,
(response: AxiosResponse) => {
const data = response.data;
if (Array.isArray(data) && data.length > 0) {
- const sectionCells = data.map((cellData) => new SectionCell({
- idSectionCell: cellData.idSectionCell,
- sectionId: cellData.sectionId,
- contentSectionCell: cellData.contentSectionCell,
- modificationDate:
- cellData.modificationDate, })
+ const sectionCells = data.map(
+ (cellData) =>
+ new SectionCell({
+ idSectionCell: cellData.idSectionCell,
+ sectionId: cellData.sectionId,
+ contentSectionCell:
+ cellData.contentSectionCell,
+ modificationDate:
+ cellData.modificationDate,
+ })
);
handleFetchSuccess(sectionCells);
} else {
- console.warn( "Aucune donnée reçue ou format inattendu :", data);
+ console.warn(
+ "Aucune donnée reçue ou format inattendu :",
+ data
+ );
}
resolve();
@@ -216,7 +241,11 @@ const fetchData = async ( projectId: number, title: number, date: string, useMoc
}
};
-const mockFetch = async ( projectId: number, title: number, date: string ): Promise => {
+const mockFetch = async (
+ projectId: number,
+ title: number,
+ date: string
+): Promise => {
console.log(
`Mock fetch pour projectId: ${projectId}, title: ${title}, date: ${date}`
);
@@ -272,8 +301,13 @@ const mockFetch = async ( projectId: number, title: number, date: string ): Prom
// On crée des instances de SectionCell
const result = section.map(
- (txt, index) => new SectionCell({ idSectionCell: index + 1, sectionId: title,
- contentSectionCell: txt, modificationDate: date, })
+ (txt, index) =>
+ new SectionCell({
+ idSectionCell: index + 1,
+ sectionId: title,
+ contentSectionCell: txt,
+ modificationDate: date,
+ })
);
return new Promise((resolve) => {
diff --git a/front/MyINPulse-front/src/components/canvas/LeanCanvas.vue b/front/MyINPulse-front/src/components/canvas/LeanCanvas.vue
index 1e72fcb..f2ef7d4 100644
--- a/front/MyINPulse-front/src/components/canvas/LeanCanvas.vue
+++ b/front/MyINPulse-front/src/components/canvas/LeanCanvas.vue
@@ -18,7 +18,7 @@ import { ref } from "vue";
import CanvasItem from "@/components/canvas/CanvasItem.vue";
const props = defineProps<{
- isAdmin: number;
+ isAdmin: boolean;
}>();
const items = ref([
diff --git a/front/MyINPulse-front/src/main.ts b/front/MyINPulse-front/src/main.ts
index 14bffbb..063a7d7 100644
--- a/front/MyINPulse-front/src/main.ts
+++ b/front/MyINPulse-front/src/main.ts
@@ -5,7 +5,6 @@ import { createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
import keycloakService from "./services/keycloak";
import { type AuthStore, useAuthStore } from "@/stores/authStore.ts";
-import { jwtDecode } from "jwt-decode";
let store: AuthStore;
@@ -29,30 +28,6 @@ keycloakService.CallInit(() => {
}
});
-
-
-type TokenPayload = {
- realm_access?: {
- roles?: string[];
- };
-};
-
-function isAdmin(): boolean{
- if (store.authenticated && store.user.token) {
- const decoded = jwtDecode(store.user.token);
- const roles = decoded.realm_access?.roles || [];
- if (roles.includes("MyINPulse-admin")) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
-}
-
-
-
// this shit made by me so i can run the canva vue app
//createApp(App).use(router).mount('#app');
diff --git a/front/MyINPulse-front/src/services/Apis/Admin.ts b/front/MyINPulse-front/src/services/Apis/Admin.ts
index bf1fa1d..2483943 100644
--- a/front/MyINPulse-front/src/services/Apis/Admin.ts
+++ b/front/MyINPulse-front/src/services/Apis/Admin.ts
@@ -1,7 +1,11 @@
import { type AxiosError, type AxiosResponse } from "axios";
import Project from "@/ApiClasses/Project";
import Report from "@/ApiClasses/Repport";
-import { axiosInstance, defaultApiErrorHandler, defaultApiSuccessHandler } from "@/services/api"
+import {
+ axiosInstance,
+ defaultApiErrorHandler,
+ defaultApiSuccessHandler,
+} from "@/services/api";
// Admin API
function getPendingAccounts(
diff --git a/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts b/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts
index 06440c2..9a3282d 100644
--- a/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts
+++ b/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts
@@ -35,7 +35,7 @@ function addSectionCell(
onErrorHandler?: (error: AxiosError) => void
): void {
axiosInstance
- .post("/entrepreneur/sectionCells", sectionCellDetails)
+ .post("/entrepreneur/sectionCells", sectionCellDetails.toPlainObject())
.then((response) => {
if (onSuccessHandler) {
onSuccessHandler(response);
diff --git a/front/MyINPulse-front/src/services/Apis/Shared.ts b/front/MyINPulse-front/src/services/Apis/Shared.ts
index ec9a52c..9850287 100644
--- a/front/MyINPulse-front/src/services/Apis/Shared.ts
+++ b/front/MyINPulse-front/src/services/Apis/Shared.ts
@@ -1,7 +1,10 @@
import { type AxiosError, type AxiosResponse } from "axios";
import Appointment from "@/ApiClasses/Appointment";
-import { axiosInstance, defaultApiErrorHandler, defaultApiSuccessHandler } from "@/services/api"
-
+import {
+ axiosInstance,
+ defaultApiErrorHandler,
+ defaultApiSuccessHandler,
+} from "@/services/api";
// Shared API
function getSectionCellsByDate(
diff --git a/front/MyINPulse-front/src/services/Apis/Unauth.ts b/front/MyINPulse-front/src/services/Apis/Unauth.ts
index c944938..229c3d0 100644
--- a/front/MyINPulse-front/src/services/Apis/Unauth.ts
+++ b/front/MyINPulse-front/src/services/Apis/Unauth.ts
@@ -1,7 +1,10 @@
import { type AxiosError, type AxiosResponse } from "axios";
-import { axiosInstance, defaultApiErrorHandler, defaultApiSuccessHandler } from "@/services/api"
-
+import {
+ axiosInstance,
+ defaultApiErrorHandler,
+ defaultApiSuccessHandler,
+} from "@/services/api";
// Unauth API
function finalizeAccount(
@@ -49,8 +52,7 @@ function finalizeAccount(
// });
// }
-
-export {
+export {
finalizeAccount,
// requestJoinProject, // Not yet implemented [cite: 4]
};
diff --git a/front/MyINPulse-front/src/services/api.ts b/front/MyINPulse-front/src/services/api.ts
index 5b62863..fe3295a 100644
--- a/front/MyINPulse-front/src/services/api.ts
+++ b/front/MyINPulse-front/src/services/api.ts
@@ -1,7 +1,7 @@
import axios, { type AxiosError, type AxiosResponse } from "axios";
import { store } from "@/main.ts";
import { addNewMessage, color } from "@/services/popupDisplayer.ts";
-import router from "@/router/router";
+import router from "@/router/router";
const axiosInstance = axios.create({
baseURL: import.meta.env.VITE_BACKEND_URL,
@@ -43,8 +43,7 @@ axiosInstance.interceptors.response.use(
// TODO: spawn a error modal
function defaultApiErrorHandler(err: AxiosError) {
const errorMessage =
- (err.response?.data as { message?: string })?.message ??
- err.message;
+ (err.response?.data as { message?: string })?.message ?? err.message;
addNewMessage(errorMessage, color.Red);
}
@@ -94,4 +93,11 @@ function deleteApi(
//export { axiosInstance, callApi, postApi, deleteApi };
-export{ axiosInstance, defaultApiErrorHandler, defaultApiSuccessHandler, callApi, postApi, deleteApi }
\ No newline at end of file
+export {
+ axiosInstance,
+ defaultApiErrorHandler,
+ defaultApiSuccessHandler,
+ callApi,
+ postApi,
+ deleteApi,
+};
diff --git a/front/MyINPulse-front/src/views/CanvasView.vue b/front/MyINPulse-front/src/views/CanvasView.vue
index 0fead7a..7337e47 100644
--- a/front/MyINPulse-front/src/views/CanvasView.vue
+++ b/front/MyINPulse-front/src/views/CanvasView.vue
@@ -10,7 +10,7 @@
Cliquez sur un champ du tableau pour afficher son contenu en détail
ci-dessous.
-
+
Responsable :
@@ -35,20 +35,18 @@ import HeaderCanvas from "../components/canvas/HeaderCanvas.vue";
import LeanCanvas from "../components/canvas/LeanCanvas.vue";
import { ref, onMounted /*, defineProps*/ } from "vue";
import { axiosInstance } from "@/services/api.ts";
-
+import { isAdmin } from "@/services/tools.ts";
const IS_MOCK_MODE = true;
-/*
+/*
const props = defineProps<{
projectId: number;
- token: TokenPayload;
}>();
+const projectId = props.projectId;
+*/
-is_admin = token.includes("MyINPulse-admin")
- */
-
-const isAdmin = 0;
+const isAdmin_: boolean = isAdmin();
// Variables pour les informations de l'administrateur
const admin = ref({