diff --git a/ArtisanConnect/api/client.jsx b/ArtisanConnect/api/client.jsx
new file mode 100644
index 0000000..6f0489c
--- /dev/null
+++ b/ArtisanConnect/api/client.jsx
@@ -0,0 +1,13 @@
+import axios from "axios";
+
+const API_URL = "https://testowe.zikor.pl/api/v1";
+
+export async function getUserById(userId) {
+ try {
+ const response = await axios.get(`${API_URL}/clients/get/${userId}`);
+ return response.data;
+ } catch (err) {
+ console.error(`Nie udało się pobrać danych użytkownika o ID ${userId}.`, err.response.status);
+ throw err;
+ }
+}
diff --git a/ArtisanConnect/app/notice/[id].jsx b/ArtisanConnect/app/notice/[id].jsx
index 5847f79..9da0bcd 100644
--- a/ArtisanConnect/app/notice/[id].jsx
+++ b/ArtisanConnect/app/notice/[id].jsx
@@ -11,6 +11,9 @@ import {useEffect, useState} from "react";
import {useNoticesStore} from "@/store/noticesStore";
import {useWishlist} from "@/store/wishlistStore";
import {Pressable} from "react-native";
+import {getUserById} from "@/api/client";
+
+
export default function NoticeDetails() {
const {id} = useLocalSearchParams();
@@ -19,6 +22,9 @@ export default function NoticeDetails() {
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState(null);
const [notice, setNotice] = useState(null);
+ const [user, setUser] = useState(null);
+ const [isUserLoading, setIsUserLoading] = useState(true);
+
const {getNoticeById, getAllImagesByNoticeId} = useNoticesStore();
const addNoticeToWishlist = useWishlist((state) => state.addNoticeToWishlist);
@@ -69,6 +75,25 @@ export default function NoticeDetails() {
}
}, [notice]);
+ useEffect(() => {
+ const fetchUser = async () => {
+ if (notice && notice.clientId) {
+ setIsUserLoading(true);
+ try {
+ const userData = await getUserById(notice.clientId);
+ setUser(userData);
+ } catch (err) {
+ console.error("Nie udało się pobrać danych użytkownika:", err);
+ } finally {
+ setIsUserLoading(false);
+ }
+ }
+ };
+
+ fetchUser();
+ }, [notice]);
+
+
if (isLoading) {
return ;
}
@@ -105,12 +130,17 @@ export default function NoticeDetails() {
+ {notice.publishDate}
+
+
{notice.title}
-
-
- {notice.price}zł
+
+
+
+ {notice.price} zł
+
{
if (isInWishlist) {
@@ -127,6 +157,47 @@ export default function NoticeDetails() {
/>
+
+
+ Kategoria: {notice.category}
+
+
+
+
+ Opis ogloszenia
+
+
+ {notice.description}
+
+
+
+
+
+ Uzytkownik:
+
+ {isUserLoading ? (
+
+ ) : user ? (
+
+
+ {user.firstName} {user.lastName}
+
+
+ Email: {user.email}
+
+
+ ) : (
+ Błąd podczas ładowania danych użytkownika
+ )}
+
+
+
+
+
+ {notice.clientId}
+
+
+
);