From 945d225a9fe0fa03dbef0d8b540abdf5be7f46bb Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Thu, 12 Jun 2025 10:13:20 +0200 Subject: [PATCH 1/3] =?UTF-8?q?ma=C5=82y=20fix=20odno=C5=9Bnie=20b=C5=82?= =?UTF-8?q?=C4=99du=20na=20starcie=20aplikacji?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArtisanConnect/app/(tabs)/index.jsx | 16 ++++++++-------- ArtisanConnect/components/UserSection.jsx | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ArtisanConnect/app/(tabs)/index.jsx b/ArtisanConnect/app/(tabs)/index.jsx index 63d8a26..b9b3099 100644 --- a/ArtisanConnect/app/(tabs)/index.jsx +++ b/ArtisanConnect/app/(tabs)/index.jsx @@ -15,15 +15,15 @@ export default function Home() { const [isReady, setIsReady] = useState(false); const fetchNotices = useNoticesStore((state) => state.fetchNotices); - // useEffect(() => { - // setIsReady(true); - // }, []); + useEffect(() => { + setIsReady(true); + }, []); - // useEffect(() => { - // if (isReady && !token) { - // router.replace("/login"); - // } - // }, [isReady, token, router]); + useEffect(() => { + if (isReady && !token) { + router.replace("/login"); + } + }, [isReady, token, router]); useEffect(() => { if (token) { diff --git a/ArtisanConnect/components/UserSection.jsx b/ArtisanConnect/components/UserSection.jsx index cf4008f..578c56d 100644 --- a/ArtisanConnect/components/UserSection.jsx +++ b/ArtisanConnect/components/UserSection.jsx @@ -20,7 +20,9 @@ export function UserSection({ notices, title }) { } }; - fetchUsers(); + if (token) { + fetchUsers(); + } }, [token]); const usersWithNoticeCount = From 67cf21230dd963b6d0eb0e402573a057345dba15 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Fri, 13 Jun 2025 17:58:14 +0200 Subject: [PATCH 2/3] 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); From 7efe9d91c35c01fbc952e7531393072a16018e79 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Fri, 13 Jun 2025 18:17:42 +0200 Subject: [PATCH 3/3] dumb fix --- ArtisanConnect/app/(tabs)/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArtisanConnect/app/(tabs)/index.jsx b/ArtisanConnect/app/(tabs)/index.jsx index b9b3099..7ee4629 100644 --- a/ArtisanConnect/app/(tabs)/index.jsx +++ b/ArtisanConnect/app/(tabs)/index.jsx @@ -29,7 +29,7 @@ export default function Home() { if (token) { fetchNotices(); } - }, [token, fetchNotices]); + }, [token]); const notices = useNoticesStore((state) => state.notices);