fix notice status

This commit is contained in:
Patryk
2025-06-08 10:30:14 +02:00
parent ca59c94783
commit e2e5543e0d
5 changed files with 523 additions and 459 deletions

View File

@@ -34,11 +34,14 @@ export default function Home() {
const notices = useNoticesStore((state) => state.notices);
// console.log("Notices:", notices);
// console.log("Notices length:", notices.length);
const latestNotices = [...notices]
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))
.slice(0, 6);
const recomendedNotices = [...notices]
const recomendedNotices = [...activeNotices]
.sort(() => Math.random() - 0.5)
.slice(0, 6);
@@ -47,13 +50,13 @@ export default function Home() {
{/* <View> */}
<SearchSection />
<ScrollView showsVerticalScrollIndicator={false}>
<CategorySection title="Polecane kategorie" notices={notices} />
<CategorySection title="Polecane kategorie" notices={activeNotices} />
<NoticeSection
title="Najnowsze ogłoszenia"
notices={latestNotices}
ctaLink="/notices?sort=latest"
/>
<UserSection title="Popularni sprzedawcy" notices={notices} />
<UserSection title="Popularni sprzedawcy" notices={activeNotices} />
<NoticeSection
title="Proponowane ogłoszenia"
notices={recomendedNotices}