Browse Source

fix(app route): condition when unregister

master
farhantock 5 months ago
parent
commit
1258f59e54
  1. 475
      src/navigation/AppRoutes.js

475
src/navigation/AppRoutes.js

@ -1,7 +1,5 @@
import React from 'react'; import React from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { config } from '@gluestack-ui/config';
import { GluestackUIProvider } from '@gluestack-ui/themed';
import { NavigationContainer } from '@react-navigation/native'; import { NavigationContainer } from '@react-navigation/native';
import { navigationRef } from './RootNavigation'; import { navigationRef } from './RootNavigation';
import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createNativeStackNavigator } from '@react-navigation/native-stack';
@ -56,12 +54,12 @@ import PostScreen from '../screens/activity/projectAset/post/index';
import DialogFormPost from '../screens/activity/projectAset/post/dialogForm'; import DialogFormPost from '../screens/activity/projectAset/post/dialogForm';
import ProjectScreen from '../screens/activity/projectAset/project/index'; import ProjectScreen from '../screens/activity/projectAset/project/index';
import DialogFormProject from '../screens/activity/projectAset/project/dialogForm'; import DialogFormProject from '../screens/activity/projectAset/project/dialogForm';
import ProfileScreen from '../screens/Profile';
const Stack = createNativeStackNavigator(); const Stack = createNativeStackNavigator();
const AppRoutes = () => { const AppRoutes = () => {
// const { isLogin } = useSelector(state => state.userReducer) const { isLogin, isRegister } = useSelector(state => state.userReducer)
// setiap kali masuk aplikasi // setiap kali masuk aplikasi
React.useEffect(() => { React.useEffect(() => {
setTimeout(async () => { setTimeout(async () => {
@ -79,228 +77,253 @@ const AppRoutes = () => {
}, []) }, [])
return ( return (
<GluestackUIProvider config={config}> <NavigationContainer ref={navigationRef}>
<NavigationContainer ref={navigationRef}> <Stack.Navigator initialRouteName='Login'>
<Stack.Navigator initialRouteName='Login'> {
<> !isLogin ?
<Stack.Screen (
options={{ headerShown: false }} <>
name="Login" <Stack.Screen
component={LoginScreen} options={{ headerShown: false }}
/> name="Login"
</> component={LoginScreen}
/>
<> </>
<Stack.Screen ) : !isRegister ? (
options={{ headerShown: false }} <>
name="App" <Stack.Screen
component={BottomTabNavigator} options={{ headerShown: false }}
/> name="Login"
<Stack.Screen component={LoginScreen}
options={{ headerShown: false }} />
name="NotificationScreen" <Stack.Screen
component={NotificationScreen} options={{ headerShown: false }}
/> name="RegisterScreen"
<Stack.Screen component={RegisterScreen}
options={{ headerShown: false }} />
name="ServiceScreen" <Stack.Screen
component={ServiceScreen} options={{ headerShown: false }}
/> name="SearchPage"
<Stack.Screen component={SearchPage}
options={{ headerShown: false }} />
name="DailyReportScreen" </>
component={DailyReportScreen} ) : (
/> <>
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="IncidentScreen" name="App"
component={IncidentScreen} component={BottomTabNavigator}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormIncident" name="NotificationScreen"
component={DialogFormIncident} component={NotificationScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="SearchPage" name="ServiceScreen"
component={SearchPage} component={ServiceScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="LocationScreen" name="DailyReportScreen"
component={LocationScreen} component={DailyReportScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="ContainedActionScreen" name="IncidentScreen"
component={ContainedActionScreen} component={IncidentScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="PresenceScreen" name="DialogFormIncident"
component={PresenceScreen} component={DialogFormIncident}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="PatroliScreen" name="SearchPage"
component={PatroliScreen} component={SearchPage}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormPatroli" name="LocationScreen"
component={DialogFormPatroli} component={LocationScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormReport" name="ContainedActionScreen"
component={DialogFormReport} component={ContainedActionScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="ActivityScreen" name="PresenceScreen"
component={ActivityScreen} component={PresenceScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormDailyReport" name="PatroliScreen"
component={DialogFormDailyReport} component={PatroliScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="ManpowerScreen" name="DialogFormPatroli"
component={ManpowerScreen} component={DialogFormPatroli}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="VisitScreen" name="DialogFormReport"
component={VisitScreen} component={DialogFormReport}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="SpesialRequestScreen" name="ActivityScreen"
component={SpesialRequestScreen} component={ActivityScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="TrainingScreen" name="DialogFormDailyReport"
component={TrainingScreen} component={DialogFormDailyReport}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="InformationScreen" name="ManpowerScreen"
component={InformationScreen} component={ManpowerScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="ShiftScreen" name="VisitScreen"
component={ShiftScreen} component={VisitScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormShift" name="SpesialRequestScreen"
component={DialogFormShift} component={SpesialRequestScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="MutationBookScreen" name="TrainingScreen"
component={MutationBookScreen} component={TrainingScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormMutationBook" name="InformationScreen"
component={DialogFormMutationBook} component={InformationScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="PersonelScreen" name="ShiftScreen"
component={PersonelScreen} component={ShiftScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="SpesialRequestAcitivityScreen" name="DialogFormShift"
component={SpesialRequestAcitivityScreen} component={DialogFormShift}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormSpesialRequest" name="MutationBookScreen"
component={DialogFormSpesialRequest} component={MutationBookScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="VisitActivityScreen" name="DialogFormMutationBook"
component={VisitActivityScreen} component={DialogFormMutationBook}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormVisit" name="PersonelScreen"
component={DialogFormVisit} component={PersonelScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="TrainingActivityScreen" name="SpesialRequestAcitivityScreen"
component={TrainingActivityScreen} component={SpesialRequestAcitivityScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormTraining" name="DialogFormSpesialRequest"
component={DialogFormTraining} component={DialogFormSpesialRequest}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="ActionActivityScreen" name="VisitActivityScreen"
component={ActionActivityScreen} component={VisitActivityScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormActivity" name="DialogFormVisit"
component={DialogFormActivity} component={DialogFormVisit}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="BriefScreen" name="TrainingActivityScreen"
component={BriefScreen} component={TrainingActivityScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormBrief" name="DialogFormTraining"
component={DialogFormBrief} component={DialogFormTraining}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="InformationDetailScreen" name="ActionActivityScreen"
component={InformationDetailScreen} component={ActionActivityScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="PatroliDRScreen" name="DialogFormActivity"
component={PatroliDRScreen} component={DialogFormActivity}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="RegisterScreen" name="BriefScreen"
component={RegisterScreen} component={BriefScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="BKOScreen" name="DialogFormBrief"
component={BKOScreen} component={DialogFormBrief}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="PPEScreen" name="InformationDetailScreen"
component={PPEScreen} component={InformationDetailScreen}
/> />
<Stack.Screen <Stack.Screen
options={{ headerShown: false }} options={{ headerShown: false }}
name="DialogFormPPE" name="PatroliDRScreen"
component={DialogFormPPE} component={PatroliDRScreen}
/> />
</> <Stack.Screen
</Stack.Navigator> options={{ headerShown: false }}
name="RegisterScreen"
</NavigationContainer> component={RegisterScreen}
</GluestackUIProvider> />
<Stack.Screen
options={{ headerShown: false }}
name="BKOScreen"
component={BKOScreen}
/>
<Stack.Screen
options={{ headerShown: false }}
name="PPEScreen"
component={PPEScreen}
/>
<Stack.Screen
options={{ headerShown: false }}
name="DialogFormPPE"
component={DialogFormPPE}
/>
<Stack.Screen
options={{ headerShown: false }}
name="ProfileScreen"
component={ProfileScreen}
/>
</>
)
}
</Stack.Navigator>
</NavigationContainer>
) )
} }

Loading…
Cancel
Save