freshyo/apps/admin-ui/app/index.tsx
2026-01-24 00:13:15 +05:30

27 lines
No EOL
703 B
TypeScript

import { Redirect } from 'expo-router';
import { useStaffAuth } from '@/components/context/staff-auth-context';
import { View, ActivityIndicator } from 'react-native';
import { AppContainer } from 'common-ui';
export default function Index() {
const { isLoggedIn, isLoading } = useStaffAuth() ;
// Show loading while checking auth
if (isLoading) {
return (
<AppContainer>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator size="large" />
</View>
</AppContainer>
);
}
if(isLoggedIn){
return <Redirect href={'/(drawer)/dashboard'} />;
}
else {
return <Redirect href={'/login'} />;
}
}