fix integration
This commit is contained in:
@@ -7,11 +7,14 @@ import { SearchSection } from "@/components/SearchSection";
|
||||
import { FlatList } from 'react-native';
|
||||
import { useAuthStore } from "@/store/authStore";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";;
|
||||
|
||||
|
||||
export default function Home() {
|
||||
const token = useAuthStore((state) => state.token);
|
||||
const router = useRouter();
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
const fetchNotices = useNoticesStore((state) => state.fetchNotices);
|
||||
|
||||
useEffect(() => {
|
||||
setIsReady(true);
|
||||
@@ -23,14 +26,25 @@ const token = useAuthStore((state) => state.token);
|
||||
}
|
||||
}, [isReady, token, router]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (token) {
|
||||
fetchNotices();
|
||||
}
|
||||
}, [token, fetchNotices]);
|
||||
|
||||
|
||||
const notices = useNoticesStore((state) => state.notices);
|
||||
const latestNotices = [...notices]
|
||||
// console.log("Notices:", 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/>
|
||||
|
||||
Reference in New Issue
Block a user