diff --git a/front/MyINPulse-front/src/components/canvas/CanvasItem.vue b/front/MyINPulse-front/src/components/canvas/CanvasItem.vue index 6d09c7c..1409680 100755 --- a/front/MyINPulse-front/src/components/canvas/CanvasItem.vue +++ b/front/MyINPulse-front/src/components/canvas/CanvasItem.vue @@ -106,26 +106,6 @@ const currentDescriptions = ref([]); 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"); - - return `${year}-${month}-${day} ${hours}:${minutes}`; -} - -onMounted(() => { - fetchData( - props.projectId, - props.title, - getCurrentFormattedDate(), - IS_MOCK_MODE - ); -}); - // Fonctions const startEditing = (index: number) => { isEditing.value[index] = true; @@ -169,7 +149,6 @@ const handleClick = () => { } }; -// fetchData const handleFetchSuccess = (sectionCells: SectionCell[]) => { currentDescriptions.value = sectionCells; editedDescriptions.value = sectionCells.map( @@ -186,8 +165,20 @@ const handleFetchSuccess = (sectionCells: SectionCell[]) => { const handleFetchError = (error: unknown) => { console.error("Erreur lors de la récupération des données :", error); + + const errorCell = new SectionCell({ + idSectionCell: -1, + sectionId: -1, + contentSectionCell: "Échec du chargement des données.", + modificationDate: new Date().toISOString(), + }); + + currentDescriptions.value = [errorCell]; + editedDescriptions.value = [errorCell]; + isEditing.value = [false]; }; + const fetchData = async ( projectId: number, title: number, @@ -314,6 +305,26 @@ const mockFetch = async ( setTimeout(() => resolve(result), 500); }); }; + +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"); + + return `${year}-${month}-${day} ${hours}:${minutes}`; +} + +onMounted(() => { + fetchData( + props.projectId, + props.title, + getCurrentFormattedDate(), + IS_MOCK_MODE + ); +});