zdjęcia pobierają się na głównej stronie + naprawiono kilka innych bugów.

takich jak wyświetlanie "Moich ogłoszeń nie dla poprawnego id etc."
This commit is contained in:
2025-06-08 22:31:52 +02:00
parent bcce392c9b
commit 2218c5eb33
8 changed files with 172 additions and 164 deletions

View File

@@ -1,6 +1,6 @@
import { useNoticesStore } from "@/store/noticesStore";
import { NoticeCard } from "@/components/NoticeCard";
import { Button, ButtonIcon, ButtonText } from "@/components/ui/button";
import { Button, ButtonText } from "@/components/ui/button";
import { Box } from "@/components/ui/box";
import { Text } from "@/components/ui/text";
@@ -12,15 +12,17 @@ import { Linking } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { useToast, Toast, ToastTitle } from "@/components/ui/toast";
import { AppState } from "react-native";
import { useAuthStore } from "@/store/authStore";
export default function UserNotices() {
const { notices, fetchNotices, deleteNotice } = useNoticesStore();
const [isLoading, setIsLoading] = useState(true);
const [isRedirecting, setIsRedirecting] = useState(false);
const currentUserId = 1;
const toast = useToast();
const appState = useRef(AppState.currentState);
const [toastId, setToastId] = useState(0);
const { user_id } = useAuthStore.getState();
const currentUserId= user_id;
useEffect(() => {
if (!isRedirecting) return;
@@ -28,9 +30,9 @@ export default function UserNotices() {
if (state === "active") {
setIsRedirecting(false);
const paymentStatus = "CORRECT";
if (paymentStatus == "INCORRECT") {
if (paymentStatus === "INCORRECT") {
showNewToast("Płatność została anulowana.");
} else if (paymentStatus == "CORRECT") {
} else if (paymentStatus === "CORRECT") {
showNewToast("Płatność została zrealizowana.");
} else {
showNewToast("Płatność jeszcze nie wpłynęła.");
@@ -83,7 +85,7 @@ export default function UserNotices() {
const paymentResult = await createPayment(); //trzeba dodać orderId
if (paymentResult) {
setIsRedirecting(true);
Linking.openURL(paymentResult);
await Linking.openURL(paymentResult);
setWaitingForPayment(true);
} else {
console.log(`Nie udało się aktywować ogłoszenia ${noticeId}.`);

View File

@@ -1,4 +1,4 @@
import { ScrollView, View } from "react-native";
import { ScrollView } from "react-native";
import { useNoticesStore } from "@/store/noticesStore";
import { CategorySection } from "@/components/CategorySection";
import { NoticeSection } from "@/components/NoticeSection";
@@ -10,7 +10,7 @@ import { useEffect, useState } from "react";
import { SafeAreaView } from "react-native";
export default function Home() {
const token = useAuthStore((state) => state.token);
const { token } = useAuthStore.getState();
const router = useRouter();
const [isReady, setIsReady] = useState(false);
const fetchNotices = useNoticesStore((state) => state.fetchNotices);
@@ -35,7 +35,7 @@ export default function Home() {
// console.log("Notices:", notices);
// console.log("Notices length:", notices.length);
const activeNotices = notices.filter((notice) => notice.status == "ACTIVE");
const activeNotices = notices.filter((notice) => notice.status === "ACTIVE");
// console.log("Activer Notices:", activeNotices.length);
const latestNotices = [...activeNotices]
.sort((a, b) => new Date(b.publishDate) - new Date(a.publishDate))

View File

@@ -4,25 +4,36 @@ import { NoticeCard } from "@/components/NoticeCard";
import { Ionicons } from "@expo/vector-icons";
import { Box } from "@/components/ui/box";
import { Text } from "@/components/ui/text";
import { useEffect } from "react";
import {useCallback} from "react";
import { useFocusEffect } from "@react-navigation/native";
export default function Wishlist() {
const wishlistNotices = useWishlist((state) => state.wishlistNotices);
const fetchWishlist = useWishlist((state) => state.fetchWishlist);
useEffect(() => {
fetchWishlist();
}, []);
useFocusEffect(
useCallback(() => {
fetchWishlist();
}, [fetchWishlist])
);
const styles = {
container: {
margin: 10,
}
}
// console.log("Wishlist notices:", wishlistNotices);
if (wishlistNotices.length === 0) {
return (
<Box className="flex-row flex-1 justify-center">
<Box style={styles.container} className="flex-row flex-1 justify-center">
<Ionicons name="sad-outline" size={24} color="black" />
<Text>Brak ulubionych ogłoszeń</Text>
</Box>
);
}
return (
<FlatList
data={wishlistNotices}
@@ -30,7 +41,6 @@ export default function Wishlist() {
numColumns={2}
columnContainerClassName="m-2"
columnWrapperClassName="gap-2 m-2"
k
renderItem={({ item }) => <NoticeCard notice={item} />}
/>
);