Browse Source

fix(app route): condition when unregister

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