fitst commit
This commit is contained in:
33
app/(dashboard)/index.tsx
Normal file
33
app/(dashboard)/index.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
// pages/home/index.tsx
|
||||
import { useAuth } from '@/components/AuthProvider';
|
||||
import { useTheme } from '@/components/ThemeContext';
|
||||
import { FilterProvider } from '@/components/ui/FilterContext';
|
||||
import { CustomHeader } from '@/components/ui/Header';
|
||||
import HomeScreen from '@/screens/home/ui/HomeScreen';
|
||||
import { router } from 'expo-router';
|
||||
import { useEffect } from 'react';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
|
||||
export default function Index() {
|
||||
const { isDark } = useTheme();
|
||||
const { isAuthenticated, isLoading } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading && !isAuthenticated) {
|
||||
router.replace('/(auth)');
|
||||
}
|
||||
}, [isAuthenticated, isLoading]);
|
||||
|
||||
if (isLoading || !isAuthenticated) {
|
||||
return null; // Loading vaqtida yoki auth yo‘q bo‘lsa hech narsa ko‘rmasin
|
||||
}
|
||||
|
||||
return (
|
||||
<FilterProvider>
|
||||
<SafeAreaView style={{ flex: 1, backgroundColor: isDark ? '#0f172a' : '#ffffff' }}>
|
||||
<CustomHeader />
|
||||
<HomeScreen />
|
||||
</SafeAreaView>
|
||||
</FilterProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user