forked from nadunchanna98/Maintenance-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp
153 lines (130 loc) · 4.62 KB
/
temp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React, { useContext } from 'react';
import { Button, View } from 'react-native';
import { createStackNavigator } from '@react-navigation/stack';
import { createDrawerNavigator } from '@react-navigation/drawer';
import UserDashboard from '../../Pages/User/UserDashboard';
import ComplainForm from '../../Pages/User/ComplainForm';
import UserProfile from '../../Pages/User/UserProfile';
import AdminDashboard from '../../Pages/Admin/AdminDashboard';
import SupervisorDashboard from '../../Pages/Superviser/SuperviserDashboard';
import LaborerDashboard from '../../Pages/Laborer/LaborerDashboard';
import { UserContext } from '../Context/UserContext';
import { AuthContext } from '../Context/AuthContext';
import NewRequests from '../../Pages/Admin/NewRequests';
import InProgressWorks from '../../Pages/Admin/InProgressWorks';
import CompletedWorks from '../../Pages/Admin/CompletedWorks';
import Supervisors from '../../Pages/Admin/Supervisors';
const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();
const AdminScreens = () => (
<>
<Drawer.Screen name="AdminDashboard" component={AdminDashboard} />
<Drawer.Screen name="NewRequests" component={NewRequests} />
<Drawer.Screen name="InProgressWorks" component={InProgressWorks} />
<Drawer.Screen name="CompletedWorks" component={CompletedWorks} />
<Drawer.Screen name="Supervisors" component={Supervisors} />
{/* Additional admin screens */}
</>
);
const SupervisorScreens = () => (
<>
<Drawer.Screen name="SupervisorDashboard"
component={SupervisorDashboard} />
{/* Additional supervisor screens */}
</>
);
const LaborerScreens = () => (
<>
<Drawer.Screen name="LaborerDashboard" component={LaborerDashboard} />
{/* Additional laborer screens */}
</>
);
const UserScreens = () => (
<>
<Drawer.Screen name="UserDashboard" component={UserDashboard} />
<Drawer.Screen name="ComplainForm" component={ComplainForm} />
{/* Additional user screens */}
</>
);
const CustomDrawerContent = ({ navigation }) => {
const { signOut } = useContext(AuthContext);
const handleLogout = () => {
signOut();
navigation.closeDrawer();
};
return (
<View style={{ flex: 1, justifyContent: 'space-between', paddingVertical: 16 }}>
{/* Drawer content */}
<View>
{/* Your drawer items here */}
</View>
{/* Logout button */}
<View>
<Button title="Logout" onPress={handleLogout} />
</View>
</View>
);
};
const AppStack = () => {
const { userInfo } = useContext(AuthContext);
return (
<Stack.Navigator>
{userInfo.role === 'admin' ? (
<Stack.Screen name="AdminDrawer"
options={{ headerShown: false }}
>
{() => (
<Drawer.Navigator
drawerContent={props => <CustomDrawerContent {...props} />}
screenOptions={{ headerShown: false }}
>
<Drawer.Screen name="AdminScreens" component={AdminDashboard} />
<Drawer.Screen name="UserProfile" component={UserProfile} />
</Drawer.Navigator>
)}
</Stack.Screen>
) : userInfo.role === 'supervisor' ? (
<Stack.Screen name="SupervisorDrawer"
options={{ headerShown: false }}
>
{() => (
<Drawer.Navigator
screenOptions={{ headerShown: false }}
>
<Drawer.Screen name="SupervisorScreens" component={SupervisorDashboard} />
<Drawer.Screen name="UserProfile" component={UserProfile} />
</Drawer.Navigator>
)}
</Stack.Screen>
) : userInfo.role === 'labour' ? (
<Stack.Screen
options={{ headerShown: false }}
name="LaborerDrawer">
{() => (
<Drawer.Navigator
screenOptions={{ headerShown: false }}
drawerContent={props => <CustomDrawerContent {...props} />}
>
<Drawer.Screen name="LaborerScreens" component={LaborerScreens} />
<Drawer.Screen name="UserProfile" component={UserProfile} />
</Drawer.Navigator>
)}
</Stack.Screen>
) : (
<Stack.Screen name="UserDrawer"
options={{ headerShown: false }}
>
{() => (
<Drawer.Navigator
screenOptions={{ headerShown: false }}
>
<Drawer.Screen name="UserScreens" component={UserDashboard} />
<Drawer.Screen name="UserProfile" component={UserProfile} />
</Drawer.Navigator>
)}
</Stack.Screen>
)}
</Stack.Navigator>
);
};
export default AppStack;