From 67cf21230dd963b6d0eb0e402573a057345dba15 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Fri, 13 Jun 2025 17:58:14 +0200 Subject: [PATCH] images were uploaded doubled --- ArtisanConnect/api/notices.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ArtisanConnect/api/notices.jsx b/ArtisanConnect/api/notices.jsx index 4a7190d..84a1867 100644 --- a/ArtisanConnect/api/notices.jsx +++ b/ArtisanConnect/api/notices.jsx @@ -42,8 +42,10 @@ export async function createNotice(notice) { for (const image of notice.image) { if (notice.image.indexOf(image) === 0) { await uploadImage(response.data.noticeId, image, true); + } else { + await uploadImage(response.data.noticeId, image, false); } - await uploadImage(response.data.noticeId, image, false); + console.log("Image uploaded successfully"); } } @@ -125,7 +127,7 @@ export const uploadImage = async (noticeId, imageObj, isFirst) => { headers: headers, } ); - console.info("Upload successful:", response.data); + console.log("Upload successful:", response.data); return response.data; } catch (error) { console.error( @@ -180,7 +182,7 @@ export const editNotice = async (noticeId, notice) => { if (response.data && notice.image && notice.image.length > 0) { for (let i = 0; i < notice.image.length; i++) { const image = notice.image[i]; - const isFirst = i == 0; + const isFirst = i === 0; if (typeof image === "string" && !image.startsWith("http")) { await uploadImage(noticeId, image, isFirst);