add required login
This commit is contained in:
@@ -51,13 +51,13 @@ export default function Login() {
|
|||||||
<VStack className="pb-4" space="xs">
|
<VStack className="pb-4" space="xs">
|
||||||
<Heading className="leading-[30px]">Logowanie</Heading>
|
<Heading className="leading-[30px]">Logowanie</Heading>
|
||||||
<Box className="flex flex-row">
|
<Box className="flex flex-row">
|
||||||
<Link href="/registration" asChild>
|
{/* <Link href="/registration" asChild> */}
|
||||||
<Button variant="link" size="sm" className="p-0">
|
<Button variant="link" size="sm" className="p-0" onPress={() => router.replace("/registration")}>
|
||||||
<ButtonText style={styles.signupbutton}>Nie masz jeszcze konta? Załóz je
|
<ButtonText style={styles.signupbutton}>Nie masz jeszcze konta? Załóz je
|
||||||
tutaj!</ButtonText>
|
tutaj!</ButtonText>
|
||||||
<ButtonIcon className="mr-1" size="md" as={ArrowRightIcon}/>
|
<ButtonIcon className="mr-1" size="md" as={ArrowRightIcon}/>
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
{/* </Link> */}
|
||||||
</Box>
|
</Box>
|
||||||
</VStack>
|
</VStack>
|
||||||
<VStack space="xl" className="py-2">
|
<VStack space="xl" className="py-2">
|
||||||
@@ -48,21 +48,10 @@ export default function TabLayout() {
|
|||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Tabs.Screen
|
|
||||||
name="login"
|
|
||||||
options={{
|
|
||||||
headerShown: false, // Ukryj nagłówek dla Drawer
|
|
||||||
title: "Authentication",
|
|
||||||
tabBarLabel: "Authentication",
|
|
||||||
tabBarIcon: ({color, size}) => (
|
|
||||||
<Ionicons name="key" size={size} color={color}/>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Tabs.Screen
|
<Tabs.Screen
|
||||||
name="dashboard"
|
name="dashboard"
|
||||||
options={{
|
options={{
|
||||||
headerShown: false, // Ukryj nagłówek dla Drawer
|
headerShown: false,
|
||||||
title: "Konto",
|
title: "Konto",
|
||||||
tabBarLabel: "Konto",
|
tabBarLabel: "Konto",
|
||||||
tabBarIcon: ({color, size}) => (
|
tabBarIcon: ({color, size}) => (
|
||||||
|
|||||||
@@ -5,8 +5,24 @@ import { NoticeSection } from "@/components/NoticeSection";
|
|||||||
import { UserSection } from "@/components/UserSection";
|
import { UserSection } from "@/components/UserSection";
|
||||||
import { SearchSection } from "@/components/SearchSection";
|
import { SearchSection } from "@/components/SearchSection";
|
||||||
import { FlatList } from 'react-native';
|
import { FlatList } from 'react-native';
|
||||||
|
import { useAuthStore } from "@/store/authStore";
|
||||||
|
import { useRouter } from "expo-router";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
export default function Home() {
|
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 notices = useNoticesStore((state) => state.notices);
|
||||||
const latestNotices = [...notices]
|
const latestNotices = [...notices]
|
||||||
.sort((a, b) => new Date(b.publishDate) - new Date(a.publishDate))
|
.sort((a, b) => new Date(b.publishDate) - new Date(a.publishDate))
|
||||||
@@ -14,6 +30,7 @@ export default function Home() {
|
|||||||
const recomendedNotices = [...notices]
|
const recomendedNotices = [...notices]
|
||||||
.sort(() => Math.random() - 0.5)
|
.sort(() => Math.random() - 0.5)
|
||||||
.slice(0, 6);
|
.slice(0, 6);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<SearchSection/>
|
<SearchSection/>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Stack } from "expo-router";
|
import { Stack, Redirect } from "expo-router";
|
||||||
import "@/global.css";
|
import "@/global.css";
|
||||||
import { GluestackUIProvider } from "@/components/ui/gluestack-ui-provider";
|
import { GluestackUIProvider } from "@/components/ui/gluestack-ui-provider";
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
import { useEffect } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useNoticesStore } from "@/store/noticesStore";
|
import { useNoticesStore } from "@/store/noticesStore";
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
export default function RootLayout() {
|
export default function RootLayout() {
|
||||||
@@ -12,9 +12,11 @@ export default function RootLayout() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchNotices();
|
fetchNotices();
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
|
||||||
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<GluestackUIProvider>
|
<GluestackUIProvider>
|
||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
screenOptions={{
|
screenOptions={{
|
||||||
headerTintColor: "#1c1c1e",
|
headerTintColor: "#1c1c1e",
|
||||||
@@ -23,6 +25,12 @@ export default function RootLayout() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||||
|
<Stack.Screen
|
||||||
|
name="(auth)/login"
|
||||||
|
options={{ headerShown: false }}/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="registration"
|
||||||
|
options={{ headerShown: false }}/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</GluestackUIProvider>
|
</GluestackUIProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import {useAuthStore} from '@/store/authStore';
|
|||||||
import {useRouter} from 'expo-router';
|
import {useRouter} from 'expo-router';
|
||||||
|
|
||||||
import {Box} from "@/components/ui/box"
|
import {Box} from "@/components/ui/box"
|
||||||
import {Button, ButtonText} from "@/components/ui/button"
|
import {Button, ButtonText,ButtonIcon} from "@/components/ui/button"
|
||||||
|
import {ArrowRightIcon} from "@/components/ui/icon"
|
||||||
import {Center} from "@/components/ui/center"
|
import {Center} from "@/components/ui/center"
|
||||||
import {Heading} from "@/components/ui/heading"
|
import {Heading} from "@/components/ui/heading"
|
||||||
import {Input, InputField} from "@/components/ui/input"
|
import {Input, InputField} from "@/components/ui/input"
|
||||||
import {VStack} from "@/components/ui/vstack"
|
import {VStack} from "@/components/ui/vstack"
|
||||||
|
import {Link} from "expo-router"
|
||||||
|
|
||||||
export default function Registration() {
|
export default function Registration() {
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
@@ -44,9 +46,18 @@ export default function Registration() {
|
|||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.container}>
|
<SafeAreaView style={styles.container}>
|
||||||
<Center>
|
<Center>
|
||||||
|
|
||||||
<Box className="p-5 w-[80%] border border-background-300 rounded-lg">
|
<Box className="p-5 w-[80%] border border-background-300 rounded-lg">
|
||||||
<VStack className="pb-4" space="xs">
|
<VStack className="pb-4" space="xs">
|
||||||
<Heading className="leading-[30px]">Rejestracja</Heading>
|
<Heading className="leading-[30px]">Rejestracja</Heading>
|
||||||
|
<Box className="flex flex-row">
|
||||||
|
{/* <Link href="/login" asChild> */}
|
||||||
|
<Button variant="link" size="sm" className="p-0" onPress={() => router.replace("/login")}>
|
||||||
|
<ButtonText style={styles.signupbutton}>Masz już konto? Zaloguj się!</ButtonText>
|
||||||
|
<ButtonIcon className="mr-1" size="md" as={ArrowRightIcon}/>
|
||||||
|
</Button>
|
||||||
|
{/* </Link> */}
|
||||||
|
</Box>
|
||||||
</VStack>
|
</VStack>
|
||||||
<VStack space="xl" className="py-2">
|
<VStack space="xl" className="py-2">
|
||||||
<Input>
|
<Input>
|
||||||
@@ -69,6 +80,7 @@ export default function Registration() {
|
|||||||
</Button>
|
</Button>
|
||||||
</VStack>
|
</VStack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
</Center>
|
</Center>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
@@ -93,4 +105,8 @@ const styles = StyleSheet.create({
|
|||||||
color: 'red',
|
color: 'red',
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
},
|
},
|
||||||
|
signupbutton: {
|
||||||
|
fontWeight: '300',
|
||||||
|
textAlign: 'left',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user