add required login

This commit is contained in:
2025-06-04 20:45:20 +02:00
parent 35efcbe3a8
commit 3bd3b9b70d
5 changed files with 51 additions and 21 deletions

View File

@@ -5,8 +5,24 @@ import { NoticeSection } from "@/components/NoticeSection";
import { UserSection } from "@/components/UserSection";
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";
export default function Home() {
const token = useAuthStore((state) => state.token);
const router = useRouter();
const [isReady, setIsReady] = useState(false);
useEffect(() => {
setIsReady(true);
}, []);
useEffect(() => {
if (isReady && !token) {
router.replace("/login");
}
}, [isReady, token, router]);
const notices = useNoticesStore((state) => state.notices);
const latestNotices = [...notices]
.sort((a, b) => new Date(b.publishDate) - new Date(a.publishDate))
@@ -14,6 +30,7 @@ export default function Home() {
const recomendedNotices = [...notices]
.sort(() => Math.random() - 0.5)
.slice(0, 6);
return (
<View>
<SearchSection/>