Files
info-tager-mobile/app/(auth)/index.tsx
Samandar Turgunboyev 124798419b fitst commit
2026-01-28 18:26:50 +05:00

40 lines
1.1 KiB
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';
import { SafeAreaView } from 'react-native-safe-area-context';
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 (
<SafeAreaView style={{ flex: 1, backgroundColor: '#0f172a' }}>
<ScrollView contentContainerStyle={{ flexGrow: 1 }}>
<LoginScreen />
</ScrollView>
</SafeAreaView>
);
}
return null;
}