From 1cc0f601fbbae067a4aff826e580c7614b8f5138 Mon Sep 17 00:00:00 2001 From: Patryk Date: Mon, 9 Jun 2025 23:57:18 +0200 Subject: [PATCH] fixes --- ArtisanConnect/api/client.jsx | 8 +- .../app/(tabs)/dashboard/userOrders.jsx | 2 +- ArtisanConnect/app/notice/[id].jsx | 56 ++++++++- ArtisanConnect/app/user/[userId].jsx | 114 ++++++++++-------- 4 files changed, 121 insertions(+), 59 deletions(-) diff --git a/ArtisanConnect/api/client.jsx b/ArtisanConnect/api/client.jsx index 4793d4d..3efb49f 100644 --- a/ArtisanConnect/api/client.jsx +++ b/ArtisanConnect/api/client.jsx @@ -12,10 +12,10 @@ export async function getUserById(userId) { }); return response.data; } catch (err) { - console.error( - `Nie udało się pobrać danych użytkownika o ID ${userId}.`, - err.response.status - ); + // console.error( + // `Nie udało się pobrać danych użytkownika o ID ${userId}.`, + // err.response.status + // ); throw err; } } diff --git a/ArtisanConnect/app/(tabs)/dashboard/userOrders.jsx b/ArtisanConnect/app/(tabs)/dashboard/userOrders.jsx index c22b2f3..a6e6e2c 100644 --- a/ArtisanConnect/app/(tabs)/dashboard/userOrders.jsx +++ b/ArtisanConnect/app/(tabs)/dashboard/userOrders.jsx @@ -32,7 +32,7 @@ export default function UserOrders() { className="m-2" data={orders} renderItem={({ item }) => ( - + {item.orderId} diff --git a/ArtisanConnect/app/notice/[id].jsx b/ArtisanConnect/app/notice/[id].jsx index 9c1a4be..31f5fde 100644 --- a/ArtisanConnect/app/notice/[id].jsx +++ b/ArtisanConnect/app/notice/[id].jsx @@ -1,4 +1,5 @@ import { Link, Stack, useLocalSearchParams } from "expo-router"; +import { KeyboardAvoidingView, Platform } from "react-native"; import { Box } from "@/components/ui/box"; import { Card } from "@/components/ui/card"; import { Heading } from "@/components/ui/heading"; @@ -287,8 +288,8 @@ export default function NoticeDetails() { - {isMessageFormVisible && ( - + {/* {isMessageFormVisible && ( + Wyślij wiadomość do {user?.firstName} @@ -332,6 +333,57 @@ export default function NoticeDetails() { + )} */} + {isMessageFormVisible && ( + + + + + Wyślij wiadomość do {user?.firstName} + + + Do: + + {user?.email || "Brak adresu e-mail"} + + Twój e-mail: + + + + + + setIsMessageFormVisible(false)} + className="bg-gray-300 py-2 px-4 rounded-md" + > + Anuluj + + + + Wyślij + + + + + )} ); diff --git a/ArtisanConnect/app/user/[userId].jsx b/ArtisanConnect/app/user/[userId].jsx index 0f85231..49c92da 100644 --- a/ArtisanConnect/app/user/[userId].jsx +++ b/ArtisanConnect/app/user/[userId].jsx @@ -10,60 +10,70 @@ import { useNoticesStore } from "@/store/noticesStore"; import { NoticeCard } from "@/components/NoticeCard"; export default function UserProfile() { - const { userId } = useLocalSearchParams(); - const [user, setUser] = useState(null); - const [isUserLoading, setIsUserLoading] = useState(true); - const { notices } = useNoticesStore(); + const { userId } = useLocalSearchParams(); + const [user, setUser] = useState(null); + const [isUserLoading, setIsUserLoading] = useState(true); + const { notices } = useNoticesStore(); - useEffect(() => { - const fetchUser = async () => { - setIsUserLoading(true); - try { - const userData = await getUserById(Number(userId)); - setUser(userData); - } catch (err) { - console.error("Błąd podczas pobierania danych użytkownika:", err); - setUser(null); - } finally { - setIsUserLoading(false); - } - }; - fetchUser(); - }, [userId]); + useEffect(() => { + const fetchUser = async () => { + setIsUserLoading(true); + try { + const userData = await getUserById(Number(userId)); + setUser(userData); + } catch (err) { + console.error("Błąd podczas pobierania danych użytkownika:", err); + setUser(null); + } finally { + setIsUserLoading(false); + } + }; + fetchUser(); + }, [userId]); - if (isUserLoading) { - return ; - } + if (isUserLoading) { + return ; + } - if (!user) { - return Nie znaleziono użytkownika; - } + if (!user) { + return Nie znaleziono użytkownika; + } - const userNotices = notices.filter(notice => notice.clientId === Number(userId)); + const userNotices = notices.filter( + (notice) => notice.clientId === Number(userId) + ); - return ( - - - Zdjęcie profilowe - - {user.firstName} {user.lastName} - - - {userNotices.length > 0 ? ( - } - keyExtractor={(item) => item.noticeId.toString()} - /> - ) : ( - Ten użytkownik nie ma żadnych ogłoszeń. - )} - - ); -} \ No newline at end of file + return ( + + + Zdjęcie profilowe + + {user.firstName} {user.lastName} + + + {userNotices.length > 0 ? ( + } + keyExtractor={(item) => item.noticeId.toString()} + /> + ) : ( + Ten użytkownik nie ma żadnych ogłoszeń. + )} + + ); +}