16 lines
466 B
TypeScript
16 lines
466 B
TypeScript
import React from 'react';
|
|
import { Redirect } from 'expo-router';
|
|
import { useAuth } from '../context/AuthContext';
|
|
|
|
export default function Index() {
|
|
const { user, isLoading } = useAuth();
|
|
|
|
// Wait for auth to settle
|
|
if (isLoading) return null;
|
|
|
|
// Smart redirect: If we have a user with an ID, go to dashboard, otherwise login
|
|
const isAuthenticated = !!(user && user.id);
|
|
|
|
return <Redirect href={isAuthenticated ? '/(tabs)' : '/(auth)/login'} />;
|
|
}
|