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 @@