From 92696c3e16900fdb07d159b37dd1c39c58f0c022 Mon Sep 17 00:00:00 2001 From: ALAMI Adnane Date: Tue, 29 Apr 2025 23:18:26 +0200 Subject: [PATCH] fix/feat: Now the projectId is correctly fetched yet we cant test shit since the db is empty --- .../src/components/canvas/CanvasItem.vue | 6 ++ .../src/components/canvas/HeaderCanvas.vue | 6 +- .../src/services/Apis/Entrepreneurs.ts | 23 ++++++++ .../MyINPulse-front/src/views/CanvasView.vue | 59 +++++++++++++++---- 4 files changed, 81 insertions(+), 13 deletions(-) diff --git a/front/MyINPulse-front/src/components/canvas/CanvasItem.vue b/front/MyINPulse-front/src/components/canvas/CanvasItem.vue index d8a7734..ccd14bf 100755 --- a/front/MyINPulse-front/src/components/canvas/CanvasItem.vue +++ b/front/MyINPulse-front/src/components/canvas/CanvasItem.vue @@ -188,6 +188,12 @@ const fetchData = async ( const responseData = await mockFetch(projectId, title, date); handleFetchSuccess(responseData); } else { + if (projectId == -1) { + console.error( + "No sections to show because no project was found." + ); + return; + } await new Promise((resolve, reject) => { getSectionCellsByDate( projectId, diff --git a/front/MyINPulse-front/src/components/canvas/HeaderCanvas.vue b/front/MyINPulse-front/src/components/canvas/HeaderCanvas.vue index ea6c847..fea3d4c 100644 --- a/front/MyINPulse-front/src/components/canvas/HeaderCanvas.vue +++ b/front/MyINPulse-front/src/components/canvas/HeaderCanvas.vue @@ -47,7 +47,7 @@ import { store } from "@/main.ts"; import { getProjectEntrepreneurs } from "@/services/Apis/Shared.ts"; import UserEntrepreneur from "@/ApiClasses/UserEntrepreneur.ts"; -const dropdownRef = ref(null); +const dropdownRef = ref(undefined); const props = defineProps<{ projectId: number; @@ -94,6 +94,10 @@ const fetchEntrepreneurs = (projectId: number, useMock = false) => { if (useMock) { fetchMockEntrepreneurs(); } else { + if (projectId == -1) { + console.error("No contact to show because no project was found."); + return; + } getProjectEntrepreneurs( projectId, (response) => { diff --git a/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts b/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts index 32e5ed8..cb10fb5 100644 --- a/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts +++ b/front/MyINPulse-front/src/services/Apis/Entrepreneurs.ts @@ -8,6 +8,28 @@ import { } from "@/services/api"; // Entrepreneurs API +function getEntrepreneurProjectId( + onSuccessHandler?: (response: AxiosResponse) => void, + onErrorHandler?: (error: AxiosError) => void +): void { + axiosInstance + .get("/entrepreneur/projects") + .then((response) => { + if (onSuccessHandler) { + onSuccessHandler(response); + } else { + defaultApiSuccessHandler(response); + } + }) + .catch((error: AxiosError) => { + if (onErrorHandler) { + onErrorHandler(error); + } else { + defaultApiErrorHandler(error); + } + }); +} + function requestProjectCreation( projectDetails: Project, onSuccessHandler?: (response: AxiosResponse) => void, @@ -102,6 +124,7 @@ function removeSectionCell( } export { + getEntrepreneurProjectId, requestProjectCreation, addSectionCell, modifySectionCell, diff --git a/front/MyINPulse-front/src/views/CanvasView.vue b/front/MyINPulse-front/src/views/CanvasView.vue index ce8eeea..975f665 100644 --- a/front/MyINPulse-front/src/views/CanvasView.vue +++ b/front/MyINPulse-front/src/views/CanvasView.vue @@ -1,7 +1,7 @@