Files
ArtisanConnectFrontend/ArtisanConnect/app/(tabs)/index.jsx
2025-06-03 20:31:16 +02:00

29 lines
1.2 KiB
JavaScript

import { ScrollView, View } from "react-native";
import { useNoticesStore } from '@/store/noticesStore';
import { CategorySection } from "@/components/CategorySection";
import { NoticeSection } from "@/components/NoticeSection";
import { UserSection } from "@/components/UserSection";
import { SearchSection } from "@/components/SearchSection";
import { FlatList } from 'react-native';
export default function Home() {
const notices = useNoticesStore((state) => state.notices);
const latestNotices = [...notices]
.sort((a, b) => new Date(b.publishDate) - new Date(a.publishDate))
.slice(0, 6);
const recomendedNotices = [...notices]
.sort(() => Math.random() - 0.5)
.slice(0, 6);
return (
<View>
<SearchSection/>
<ScrollView showsVerticalScrollIndicator={false} className='m-2'>
<CategorySection title="Polecane kategorie" notices={notices} />
<NoticeSection title="Najnowsze ogłoszenia" notices={latestNotices} ctaLink="/notices?sort=latest"/>
<UserSection title="Popularni sprzedawcy" notices={notices} />
<NoticeSection title="Proponowane ogłoszenia" notices={recomendedNotices} ctaLink="/notices"/>
</ScrollView>
</View>
);
}