Files
info-target-mobile/app/(auth)/index.tsx
Samandar Turgunboyev d747c72c8d complated
2026-02-17 10:46:57 +05:00

39 lines
1014 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useAuth } from '@/components/AuthProvider';
import LoginScreen from '@/screens/auth/login/ui/LoginScreens';
import { router } from 'expo-router';
import { useEffect } from 'react';
import { ActivityIndicator, ScrollView, View } from 'react-native';
export default function Index() {
const { isAuthenticated, isLoading } = useAuth();
// Loading spinner
if (isLoading) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator size="large" color="#3b82f6" />
</View>
);
}
// Token bolsa dashboard-ga yonaltir
useEffect(() => {
if (isAuthenticated) {
router.replace('/(dashboard)');
}
}, [isAuthenticated]);
// Token yoq → login screen
if (!isAuthenticated) {
return (
<View style={{ flex: 1, backgroundColor: '#0f172a' }}>
<ScrollView contentContainerStyle={{ flexGrow: 1 }}>
<LoginScreen />
</ScrollView>
</View>
);
}
return null;
}