fixes
This commit is contained in:
@@ -12,10 +12,10 @@ export async function getUserById(userId) {
|
|||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
// console.error(
|
||||||
`Nie udało się pobrać danych użytkownika o ID ${userId}.`,
|
// `Nie udało się pobrać danych użytkownika o ID ${userId}.`,
|
||||||
err.response.status
|
// err.response.status
|
||||||
);
|
// );
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default function UserOrders() {
|
|||||||
className="m-2"
|
className="m-2"
|
||||||
data={orders}
|
data={orders}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<Box className="p-4 rounded-md bg-white">
|
<Box className="p-4 rounded-md bg-white mb-2">
|
||||||
<VStack>
|
<VStack>
|
||||||
<HStack>
|
<HStack>
|
||||||
<Text>{item.orderId}</Text>
|
<Text>{item.orderId}</Text>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Link, Stack, useLocalSearchParams } from "expo-router";
|
import { Link, Stack, useLocalSearchParams } from "expo-router";
|
||||||
|
import { KeyboardAvoidingView, Platform } from "react-native";
|
||||||
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";
|
||||||
@@ -287,8 +288,8 @@ export default function NoticeDetails() {
|
|||||||
</Box>
|
</Box>
|
||||||
</VStack>
|
</VStack>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
{isMessageFormVisible && (
|
{/* {isMessageFormVisible && (
|
||||||
<View className="absolute inset-0 bg-black bg-opacity-50 justify-center items-center z-20">
|
<View className="absolute inset-0 bg-black/50 bg-opacity-50 justify-center items-center z-20">
|
||||||
<View className="bg-white p-4 rounded-lg w-4/5">
|
<View className="bg-white p-4 rounded-lg w-4/5">
|
||||||
<Text className="text-lg font-bold mb-4">
|
<Text className="text-lg font-bold mb-4">
|
||||||
Wyślij wiadomość do {user?.firstName}
|
Wyślij wiadomość do {user?.firstName}
|
||||||
@@ -332,6 +333,57 @@ export default function NoticeDetails() {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
)} */}
|
||||||
|
{isMessageFormVisible && (
|
||||||
|
<KeyboardAvoidingView
|
||||||
|
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
||||||
|
className="absolute inset-0 bg-black/50 justify-center items-center z-20"
|
||||||
|
>
|
||||||
|
<View className="bg-white p-4 rounded-lg w-4/5 max-h-4/5">
|
||||||
|
<ScrollView showsVerticalScrollIndicator={false}>
|
||||||
|
<Text className="text-lg font-bold mb-4">
|
||||||
|
Wyślij wiadomość do {user?.firstName}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Text className="text-sm font-medium mb-1">Do:</Text>
|
||||||
|
<Text className="bg-gray-100 p-3 rounded text-gray-500">
|
||||||
|
{user?.email || "Brak adresu e-mail"}
|
||||||
|
</Text>
|
||||||
|
<Text className="text-sm font-medium mb-1">Twój e-mail:</Text>
|
||||||
|
<TextInput
|
||||||
|
className="border border-gray-300 p-2 rounded mb-4"
|
||||||
|
placeholder="Wpisz swój adres e-mail"
|
||||||
|
value={Email}
|
||||||
|
onChangeText={setEmail}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
className="border border-gray-300 rounded-md p-2 mb-4 h-32 text-left"
|
||||||
|
multiline
|
||||||
|
numberOfLines={4}
|
||||||
|
placeholder="Napisz swoją wiadomość..."
|
||||||
|
value={message}
|
||||||
|
onChangeText={setMessage}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<View className="flex-row justify-end space-x-2">
|
||||||
|
<Pressable
|
||||||
|
onPress={() => setIsMessageFormVisible(false)}
|
||||||
|
className="bg-gray-300 py-2 px-4 rounded-md"
|
||||||
|
>
|
||||||
|
<Text className="text-gray-800">Anuluj</Text>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Pressable
|
||||||
|
onPress={handleSendMessage}
|
||||||
|
className="bg-primary-500 py-2 px-4 rounded-md"
|
||||||
|
>
|
||||||
|
<Text className="text-white">Wyślij</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,60 +10,70 @@ import { useNoticesStore } from "@/store/noticesStore";
|
|||||||
import { NoticeCard } from "@/components/NoticeCard";
|
import { NoticeCard } from "@/components/NoticeCard";
|
||||||
|
|
||||||
export default function UserProfile() {
|
export default function UserProfile() {
|
||||||
const { userId } = useLocalSearchParams();
|
const { userId } = useLocalSearchParams();
|
||||||
const [user, setUser] = useState(null);
|
const [user, setUser] = useState(null);
|
||||||
const [isUserLoading, setIsUserLoading] = useState(true);
|
const [isUserLoading, setIsUserLoading] = useState(true);
|
||||||
const { notices } = useNoticesStore();
|
const { notices } = useNoticesStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchUser = async () => {
|
const fetchUser = async () => {
|
||||||
setIsUserLoading(true);
|
setIsUserLoading(true);
|
||||||
try {
|
try {
|
||||||
const userData = await getUserById(Number(userId));
|
const userData = await getUserById(Number(userId));
|
||||||
setUser(userData);
|
setUser(userData);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Błąd podczas pobierania danych użytkownika:", err);
|
console.error("Błąd podczas pobierania danych użytkownika:", err);
|
||||||
setUser(null);
|
setUser(null);
|
||||||
} finally {
|
} finally {
|
||||||
setIsUserLoading(false);
|
setIsUserLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchUser();
|
fetchUser();
|
||||||
}, [userId]);
|
}, [userId]);
|
||||||
|
|
||||||
if (isUserLoading) {
|
if (isUserLoading) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return <Text>Nie znaleziono użytkownika</Text>;
|
return <Text>Nie znaleziono użytkownika</Text>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userNotices = notices.filter(notice => notice.clientId === Number(userId));
|
const userNotices = notices.filter(
|
||||||
|
(notice) => notice.clientId === Number(userId)
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VStack className="p-4">
|
<VStack className="p-4">
|
||||||
<Box className="flex-row items-center mb-4">
|
<Box className="flex-row items-center mb-4">
|
||||||
<Image
|
<Image
|
||||||
source={{ uri: user.profileImage || "https://th.bing.com/th/id/OIP.3coo_N8sieled8QNroQmkgHaHa?rs=1&pid=ImgDetMain" }}
|
source={{
|
||||||
className="h-16 w-16 rounded-full mr-4"
|
uri:
|
||||||
alt="Zdjęcie profilowe"
|
user.profileImage ||
|
||||||
/>
|
"https://th.bing.com/th/id/OIP.3coo_N8sieled8QNroQmkgHaHa?rs=1&pid=ImgDetMain",
|
||||||
<Heading size="lg">
|
}}
|
||||||
{user.firstName} {user.lastName}
|
className="h-16 w-16 rounded-full mr-4"
|
||||||
</Heading>
|
alt="Zdjęcie profilowe"
|
||||||
</Box>
|
/>
|
||||||
{userNotices.length > 0 ? (
|
<Heading size="lg">
|
||||||
<FlatList
|
{user.firstName} {user.lastName}
|
||||||
data={userNotices}
|
</Heading>
|
||||||
numColumns={2}
|
</Box>
|
||||||
columnWrapperStyle={{ marginBottom: 10, justifyContent: "space-between" }}
|
{userNotices.length > 0 ? (
|
||||||
renderItem={({ item }) => <NoticeCard notice={item} />}
|
<FlatList
|
||||||
keyExtractor={(item) => item.noticeId.toString()}
|
data={userNotices}
|
||||||
/>
|
numColumns={2}
|
||||||
) : (
|
columnWrapperStyle={{
|
||||||
<Text>Ten użytkownik nie ma żadnych ogłoszeń.</Text>
|
marginBottom: 10,
|
||||||
)}
|
justifyContent: "space-between",
|
||||||
</VStack>
|
gap: 8,
|
||||||
);
|
}}
|
||||||
}
|
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