-
Notifications
You must be signed in to change notification settings - Fork 6
/
Routes.js
318 lines (279 loc) · 9.85 KB
/
Routes.js
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
import React, { useEffect, useState } from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
import { useDispatch, useSelector } from 'react-redux';
import InitialLoader from './screens/InitialLoader';
import Onboard from './navigations/Onboard';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { setInstalled, setUnInstalled } from './redux/appReducer';
import { LoginScreen } from './screens/LoginScreen/LoginScreen';
import { AuthScreen } from './screens/AuthScreen/AuthScreen';
import { resetAllCat } from './redux/catReducer';
import MyDrawer from './navigations/MyDrawer';
import { Expense, Income } from './screens';
import { COLORS, icons } from './constants';
import Details from './screens/Product/Details';
import AddProduct from './screens/Product/AddProduct';
import { loginSuccess } from './redux/authReducer';
import { EditProfile, SignUpScreen } from './screens/SignUpScreen';
import EditProduct from './screens/Product/EditProduct';
import ShowImages from './screens/Product/ShowImages';
import ShoppingCard from './screens/ShoppingCard/ShoppingCard';
import { AideEtSupport, DataSecurityScreen, DetailsByUser, LanguageSelectionScreen, MagicValidation, Privacy, Profile, ReportProblemScreen, UseCondition } from './screens/Settings';
import { AddAvec, ConfirmPayment, DetailsAvec, DetailsReunion, EditAvec } from './screens/CreanceDette';
import { StatusBar } from 'expo-status-bar';
import CountyPhone from './screens/Auth/Component/CountyPhone';
import Account from './screens/Auth/Component/Account';
import OTP from './screens/Auth/Component/OTP';
import { ForgetPassword } from './screens/LoginScreen/components/ForgetPassword';
import { ResetPasswordProfile } from './screens/SignUpScreen/components/ResetPasswordProfile';
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
border: 'transparent',
},
};
const Stack = createStackNavigator();
const App = () => {
const [loading, setLoading] = useState(true);
const dispatch = useDispatch();
const [fontLoading, setFontLoading] = useState(false);
const isInstalled = useSelector((state) => state.app.isInstalled);
const u = useSelector((state) => state?.user);
const income = 'income';
const expense = 'expense';
const cat = [
{
id: 1,
name: 'Vente',
icon: icons.shopping,
cat: income,
color: COLORS.purple,
data: [],
},
{
id: 2,
name: 'Remboursement',
icon: icons.refund,
cat: income,
color: COLORS.blue,
data: [],
},
{
id: 3,
name: 'Intérêt',
icon: icons.interest,
cat: income,
color: COLORS.darkgreen,
data: [],
},
{
id: 4,
name: 'Subvention',
icon: icons.grant,
cat: income,
color: COLORS.red,
data: [],
},
{
id: 5,
name: 'Investissement',
icon: icons.investment,
cat: income,
color: COLORS.peach,
data: [],
},
{
id: 6,
name: 'Achat',
icon: icons.shopping,
cat: expense,
color: COLORS.lightBlue,
data: [],
},
{
id: 7,
name: 'Salaire',
icon: icons.cash,
cat: expense,
color: COLORS.peach,
data: [],
},
{
id: 8,
name: "Dépenses d'exploitation",
icon: icons.cashbook,
cat: expense,
color: COLORS.darkgreen,
data: [],
},
{
id: 9,
name: "Retraits d'argent",
icon: icons.sell,
cat: expense,
color: COLORS.red,
data: [],
},
{
id: 10,
name: 'Paiements de dettes',
icon: icons.income,
cat: expense,
color: COLORS.yellow,
data: [],
},
{
id: 11,
name: 'Autres entrées',
icon: icons.more,
cat: income,
color: COLORS.gray,
data: [],
},
{
id: 12,
name: 'Autres Sorties',
icon: icons.more,
cat: expense,
color: COLORS.purple,
data: [],
},
];
useEffect(() => {
checkLoginStatus();
setTimeout(() => setLoading(false), 2000);
// AsyncStorage.clear();
checkInstallationStatus();
checkCategories();
}, []);
const checkInstallationStatus = async () => {
try {
const value = await AsyncStorage.getItem('isInstalled');
console.log('installed', value);
if (value !== null && value === 'true') {
dispatch(setInstalled());
} else {
setLoading(false);
dispatch(setUnInstalled());
}
} catch (error) {
console.log('Error retrieving installation status:', error);
setLoading(false);
}
};
const checkLoginStatus = async () => {
try {
const value = await AsyncStorage.getItem('user');
// AsyncStorage.clear();
console.log('value-user', value);
if (value !== null) {
dispatch(loginSuccess(value));
//AsyncStorage.clear();
//dispatch(logoutUser());
} else {
//setLoading(false);
//dispatch(setUnInstalled());
}
} catch (error) {
console.log('Error retrieving installation status:', error);
//setLoading(false);
}
};
const checkCategories = async () => {
try {
const value = await AsyncStorage.getItem('categories');
//console.log('----------', value);
if (value !== null) {
//dispatch(addCat(JSON.parse(value)));
dispatch(resetAllCat(JSON.parse(value)));
} else {
// setLoading(false);
dispatch(resetAllCat([...cat]));
}
} catch (error) {
console.log('Error retrieving categories status:', error);
setLoading(false);
}
};
if (loading) {
return <InitialLoader />;
}
if (isInstalled) {
return (
<NavigationContainer theme={theme}>
<StatusBar style="dark" />
<Stack.Navigator initialRouteName={'MyDrawer'}>
<Stack.Screen
name="Main"
component={MyDrawer}
options={{
headerShown: false,
initialParams: { guy: "l" }, // Pass the value as initialParams
}}
/>
<Stack.Screen name="Income" component={Income} options={{ title: 'Crédit (Entrée)' }} />
<Stack.Screen name="Expense" component={Expense} options={{ title: 'Débit (Sortie)' }} />
<Stack.Screen name="Details" component={Details} options={{ title: 'Details' }} />
<Stack.Screen name="AddProduct" component={AddProduct}
options={{ title: 'Ajouter un Produit ou Service' }} />
<Stack.Screen name="EditProduct" component={EditProduct} options={{ title: 'Modifier Produit' }} />
<Stack.Screen name="ShowImages" component={ShowImages} options={{ title: 'Images' }} />
<Stack.Screen name="ShoppingCard" component={ShoppingCard} options={{ title: 'Panier' }} />
<Stack.Screen name="Privacy" component={Privacy} options={{ title: 'Politique de Confidentialité' }} />
<Stack.Screen name="DataSecurityScreen" component={DataSecurityScreen} options={{ title: 'Sécurité des Données' }} />
<Stack.Screen name="AideEtSupport" component={AideEtSupport} options={{ title: 'Aide et Support' }} />
<Stack.Screen name="UseCondition" component={UseCondition} options={{ title: "Condition d'utilisation" }} />
<Stack.Screen name="ReportProblemScreen" component={ReportProblemScreen} options={{ title: "Signaler un problème" }} />
<Stack.Screen name="LanguageSelectionScreen" component={LanguageSelectionScreen} options={{ title: "Choisissez une Langue" }} />
<Stack.Screen name="MagicValidation" component={MagicValidation} options={{ title: "Magic Validation" }} />
<Stack.Screen name="DetailsByUser" component={DetailsByUser}
options={{ title: '', headerShown: true }} />
<Stack.Screen name="addAvec" component={AddAvec}
options={{ title: 'Ajouter un groupe', headerShown: true }} />
<Stack.Screen name="DetailsAvec" component={DetailsAvec}
options={{ title: 'Details', headerShown: true }} />
<Stack.Screen name="DetailsReunion" component={DetailsReunion}
options={{ title: 'Details Reunion', headerShown: true }} />
<Stack.Screen name="ConfirmPayment" component={ConfirmPayment}
options={{ title: 'Confirmation', headerShown: true }} />
<Stack.Screen name="EditAvec" component={EditAvec}
options={{ title: 'Modifier AVEC', headerShown: true }} />
<Stack.Screen name="EditProfile" component={EditProfile} options={{
headerShown: false,
}} />
<Stack.Screen name="Profile" component={Profile} options={{ title: "Profile" }} />
<Stack.Screen name="LoginScreen" component={LoginScreen} options={{
headerShown: false,
}} />
<Stack.Screen name="SignUpScreen" component={SignUpScreen} options={{
headerShown: false,
}} />
<Stack.Screen name="ForgetPassword" component={ForgetPassword} options={{
headerShown: false,
}} />
<Stack.Screen name="ResetPasswordProfile" component={ResetPasswordProfile} options={{
headerShown: false,
}} />
<Stack.Screen name="AuthScreen" component={AuthScreen} options={{
headerShown: false,
}} />
<Stack.Screen name="CountyPhone" component={CountyPhone} options={{
headerShown: false,
}} />
<Stack.Screen name="Account" component={Account} options={{
headerShown: false,
}} />
<Stack.Screen name="OTP" component={OTP} options={{
headerShown: false,
}} />
</Stack.Navigator>
</NavigationContainer>
);
} else if (!isInstalled) {
return <Onboard />;
}
return <InitialLoader />;
};
export default App;