From 8722488a45df11f0f200796b6b2fde46aa77914a Mon Sep 17 00:00:00 2001 From: Kuba Date: Tue, 3 Jun 2025 00:19:12 +0200 Subject: [PATCH] Added content to account.jsx and userNotices.jsx --- .../app/(tabs)/dashboard/account.jsx | 74 +++++++++++++++++- .../app/(tabs)/dashboard/userNotices.jsx | 77 ++++++++++++++++++- 2 files changed, 144 insertions(+), 7 deletions(-) diff --git a/ArtisanConnect/app/(tabs)/dashboard/account.jsx b/ArtisanConnect/app/(tabs)/dashboard/account.jsx index 7d3093d..25d74a6 100644 --- a/ArtisanConnect/app/(tabs)/dashboard/account.jsx +++ b/ArtisanConnect/app/(tabs)/dashboard/account.jsx @@ -1,4 +1,70 @@ -import { Text } from "@/components/ui/text"; -export default function User() { - return Użytkownik; -} +import { Link } from "expo-router"; +import {Button} from "react-native"; +import {Box} from "@/components/ui/box"; +import {Text} from "@/components/ui/text"; +import {VStack} from "@/components/ui/vstack"; +import {Image} from "@/components/ui/image"; +import {ActivityIndicator, } from "react-native"; +import {useEffect, useState} from "react"; +import {getUserById} from "@/api/client"; + +export default function Account() { + const [user, setUser] = useState(null); + const [isLoading, setIsLoading] = useState(true); + const currentUserId = 1; // Tymczasowo, do czasu zaimplementowania logowania bo nie moge pobrac usera + + useEffect(() => { + const fetchUser = async () => { + setIsLoading(true); + try { + const userData = await getUserById(currentUserId); + setUser(userData); + } catch (err) { + console.error("Błąd podczas pobierania danych użytkownika:", err); + } finally { + setIsLoading(false); + } + }; + fetchUser(); + }, []); + + if (isLoading) { + return ; + } + + if (!user) { + return Nie udało się pobrać danych użytkownika.; + } + + return ( + + + Zdjęcie profilowe + + {user.firstName} {user.lastName} + + + + + + Moje ogłoszenia + + + Moje płatności + + + + ); +} \ No newline at end of file diff --git a/ArtisanConnect/app/(tabs)/dashboard/userNotices.jsx b/ArtisanConnect/app/(tabs)/dashboard/userNotices.jsx index 9f5ef2f..7fe0f2b 100644 --- a/ArtisanConnect/app/(tabs)/dashboard/userNotices.jsx +++ b/ArtisanConnect/app/(tabs)/dashboard/userNotices.jsx @@ -1,4 +1,75 @@ -import { Text } from "@/components/ui/text"; +import { useNoticesStore } from "@/store/noticesStore"; +import { NoticeCard } from "@/components/NoticeCard"; +import {Button} from "react-native"; +import {Box} from "@/components/ui/box"; +import {Text} from "@/components/ui/text"; +import {VStack} from "@/components/ui/vstack"; +import {ActivityIndicator, FlatList } from "react-native"; +import {useEffect, useState} from "react"; + export default function UserNotices() { - return Użytkownik; -} + const { notices, fetchNotices } = useNoticesStore(); + const [isLoading, setIsLoading] = useState(true); + const currentUserId = 1; // Tymczasowo, do czasu zaimplementowania logowania bo nie moge pobrac usera + + useEffect(() => { + const loadNotices = async () => { + setIsLoading(true); + try { + await fetchNotices(); + } catch (err) { + console.error("Błąd podczas pobierania ogłoszeń:", err); + } finally { + setIsLoading(false); + } + }; + loadNotices(); + }, []); + + const userNotices = notices.filter(notice => notice.clientId === currentUserId); + + if (isLoading) { + return ; + } + + return ( + + Moje ogłoszenia + {userNotices.length > 0 ? ( + ( + + + + + + + + )} + keyExtractor={(item) => item.noticeId.toString()} + /> + ) : ( + Nie masz żadnych ogłoszeń. + )} + + ); +} \ No newline at end of file