-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (67 loc) · 2.1 KB
/
index.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
/*
* Copyright (c) Hear Ye LLC and its affiliates
*
* This source code is licensed under the Apache 2.0 license found
* in the LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
import {Navigation} from 'react-native-navigation';
import './src/globals.js';
import {LandingScreen, OnboardingModal, SelectDistrict} from './src/Landing';
import {loginNavigationRoot, dashboardNavigationRoot} from './src/utils';
import Dashboard from './src/Dashboard';
import {SummaryScreen} from './src/Dashboard/Summary';
import RepresentativeScreen from './src/Dashboard/Representative';
import {Authenticate, userStillNeeds} from './src/api/components/auth';
import PersonalDetailScreen from './src/Personal';
import SettingsScreen from './src/Personal/Settings';
for (const [_component_id, _component] of [
['LandingScreen', LandingScreen],
['Dashboard', Dashboard],
['SummaryScreen', SummaryScreen],
['SELECT_DISTRICT_MODAL', SelectDistrict],
['ONBOARDING_MODAL', OnboardingModal],
['RepresentativeScreen', RepresentativeScreen],
['PersonalDetailScreen', PersonalDetailScreen],
['SettingsScreen', SettingsScreen],
]) {
Navigation.registerComponent(_component_id, () => _component);
}
Navigation.events().registerAppLaunchedListener(async () => {
const data = await Authenticate(true);
await Navigation.setRoot(
data ? dashboardNavigationRoot : loginNavigationRoot,
);
const stillNeeds = userStillNeeds(data);
if (typeof stillNeeds === 'boolean') {
return;
}
if (stillNeeds.includes(1)) {
await Navigation.showModal({
stack: {
children: [
{
component: {
name: 'SELECT_DISTRICT_MODAL',
options: {
topBar: {
title: {
text: 'Select your current district',
},
},
hardwareBackButton: {
dismissModalOnPress: false,
},
modal: {
swipeToDismiss: false,
},
},
},
},
],
},
});
}
});