First commit of the new app
This commit is contained in:
29
app/index.tsx
Normal file
29
app/index.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { LoadingSpinner } from '@/assets/components/LoadingSpinner';
|
||||
import { useAuth } from '@/assets/contexts/useAuth';
|
||||
import { type Href, router } from 'expo-router';
|
||||
import { useEffect } from 'react';
|
||||
import { View } from 'react-native';
|
||||
import styles from '@/styles/screens/root/index.styles';
|
||||
|
||||
export default function Index() {
|
||||
const { isAuthenticated, isLoading } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading) {
|
||||
if (isAuthenticated) {
|
||||
// Se estiver autenticado, redirecionar para home
|
||||
router.replace('/home' as Href);
|
||||
} else {
|
||||
// Se não estiver autenticado, redirecionar para login
|
||||
router.replace('/login' as Href);
|
||||
}
|
||||
}
|
||||
}, [isAuthenticated, isLoading]);
|
||||
|
||||
// Mostrar loading enquanto verifica autenticação
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<LoadingSpinner size="large" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user