added the ability to see the notices of a particular user(transition from the notice)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import {Stack, useLocalSearchParams} from "expo-router";
|
import {Link, Stack, useLocalSearchParams} from "expo-router";
|
||||||
import {Box} from "@/components/ui/box";
|
import {Box} from "@/components/ui/box";
|
||||||
import {Card} from "@/components/ui/card";
|
import {Card} from "@/components/ui/card";
|
||||||
import {Heading} from "@/components/ui/heading";
|
import {Heading} from "@/components/ui/heading";
|
||||||
@@ -6,7 +6,7 @@ import {Image} from "@/components/ui/image";
|
|||||||
import {Text} from "@/components/ui/text";
|
import {Text} from "@/components/ui/text";
|
||||||
import {VStack} from "@/components/ui/vstack";
|
import {VStack} from "@/components/ui/vstack";
|
||||||
import {Ionicons} from "@expo/vector-icons";
|
import {Ionicons} from "@expo/vector-icons";
|
||||||
import {ActivityIndicator, Dimensions, FlatList, View, TextInput} from "react-native";
|
import {ActivityIndicator, Dimensions, FlatList, View, TextInput, TouchableOpacity} from "react-native";
|
||||||
import {useEffect, useState, useRef} from "react";
|
import {useEffect, useState, useRef} from "react";
|
||||||
import {useNoticesStore} from "@/store/noticesStore";
|
import {useNoticesStore} from "@/store/noticesStore";
|
||||||
import {useWishlist} from "@/store/wishlistStore";
|
import {useWishlist} from "@/store/wishlistStore";
|
||||||
@@ -267,6 +267,11 @@ export default function NoticeDetails() {
|
|||||||
>
|
>
|
||||||
<Text className="text-white text-center font-bold">Wyślij wiadomość</Text>
|
<Text className="text-white text-center font-bold">Wyślij wiadomość</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
<Link href={`/user/${notice.clientId}`}>
|
||||||
|
<Text className="text-sm text-typography-700 mt-3">
|
||||||
|
Zobacz więcej ogłoszeń od {user.firstName}
|
||||||
|
</Text>
|
||||||
|
</Link>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
69
ArtisanConnect/app/user/[userId].jsx
Normal file
69
ArtisanConnect/app/user/[userId].jsx
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import { useLocalSearchParams } from "expo-router";
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { FlatList, ActivityIndicator, Text } from "react-native";
|
||||||
|
import { Box } from "@/components/ui/box";
|
||||||
|
import { Image } from "@/components/ui/image";
|
||||||
|
import { VStack } from "@/components/ui/vstack";
|
||||||
|
import { Heading } from "@/components/ui/heading";
|
||||||
|
import { getUserById } from "@/api/client";
|
||||||
|
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();
|
||||||
|
|
||||||
|
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 <ActivityIndicator />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return <Text>Nie znaleziono użytkownika</Text>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const userNotices = notices.filter(notice => notice.clientId === Number(userId));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<VStack className="p-4">
|
||||||
|
<Box className="flex-row items-center mb-4">
|
||||||
|
<Image
|
||||||
|
source={{ uri: user.profileImage || "https://th.bing.com/th/id/OIP.3coo_N8sieled8QNroQmkgHaHa?rs=1&pid=ImgDetMain" }}
|
||||||
|
className="h-16 w-16 rounded-full mr-4"
|
||||||
|
alt="Zdjęcie profilowe"
|
||||||
|
/>
|
||||||
|
<Heading size="lg">
|
||||||
|
{user.firstName} {user.lastName}
|
||||||
|
</Heading>
|
||||||
|
</Box>
|
||||||
|
{userNotices.length > 0 ? (
|
||||||
|
<FlatList
|
||||||
|
data={userNotices}
|
||||||
|
numColumns={2}
|
||||||
|
columnWrapperStyle={{ marginBottom: 10, justifyContent: "space-between" }}
|
||||||
|
renderItem={({ item }) => <NoticeCard notice={item} />}
|
||||||
|
keyExtractor={(item) => item.noticeId.toString()}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Text>Ten użytkownik nie ma żadnych ogłoszeń.</Text>
|
||||||
|
)}
|
||||||
|
</VStack>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user