add search section to home

This commit is contained in:
2025-06-03 20:31:16 +02:00
parent 0bae3bf212
commit f05d5b7500
5 changed files with 48 additions and 6 deletions

View File

@@ -1,8 +1,9 @@
import { ScrollView, Text } from "react-native";
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() {
@@ -14,11 +15,14 @@ export default function Home() {
.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>
);
}

View File

@@ -11,7 +11,6 @@ import { listCategories } from "@/api/categories";
import { FormControl, FormControlLabel } from "@/components/ui/form-control";
import { Input, InputField } from "@/components/ui/input";
import { HStack } from "@/components/ui/hstack";
import {
Actionsheet,
ActionsheetContent,
@@ -95,8 +94,16 @@ export default function Notices() {
});
}
if (params.search) {
const searchTerm = params.search.toLowerCase();
result = result.filter(notice =>{
return notice.title.toLowerCase().includes(searchTerm);
});
}
setFilteredNotices(result);
}, [notices, params.category, params.sort, params.priceFrom, params.priceTo]);
}, );
let filterActive = !!params.category || params.sort === "latest";