-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
90 lines (85 loc) · 2.4 KB
/
main.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
import React from 'react';
import CompanyCodePage from './companySelector/index';
import Login from './login/index';
import Navigation from './navigation/index';
import {COLOR, ThemeProvider} from 'react-native-material-ui';
import {connect} from 'react-redux';
const uiTheme = {
palett: {
primaryColor: COLOR.green500,
},
toolbar: {
container: {
height: 50,
},
},
};
class Main extends React.Component {
constructor(props) {
super(props);
//disables the yellow box
console.disableYellowBox = true;
}
render() {
if (this.props.loggedIn) {
return (
<ThemeProvider uiTheme={uiTheme}>
<Navigation
screenProps={{
dispatch: this.props.dispatch,
company: this.props.company,
employee: this.props.employee,
timeclock: this.props.timeclock,
}}
/>
</ThemeProvider>
);
} else if (this.props.companyFound) {
return (
<ThemeProvider uiTheme={uiTheme}>
<Login
dispatch={this.props.dispatch}
error={this.props.loginError}
errorMessage={this.props.loginErrorMessage}
logo={this.props.companyID}
remember={this.props.loginRemember}
data={this.props.companyData}
/>
</ThemeProvider>
);
} else {
return (
<ThemeProvider uiTheme={uiTheme}>
<CompanyCodePage
dispatch={this.props.dispatch}
error={this.props.companyNotFound}
invalid={this.props.companyCodeInvalid}
info={this.props.companyCodeInfo}
/>
</ThemeProvider>
);
}
}
}
const mapStateToProps = state => {
const companyNotFound = !state.company.found && state.company.code != '';
return {
...state,
companyNotFound: companyNotFound,
companyFound: state.company.found,
companyCodeInfo: state.company.info,
companyCodeInvalid: state.company.invalid,
companyID: state.company.code,
companyData: state.company.data,
loggedIn: state.employee.loggedIn,
loginError: state.employee.failed,
loginErrorMessage: state.employee.message,
loginRemember: {
remember: state.employee.remember,
username: state.employee.username,
password: state.employee.password,
},
timeclock: state.timeclock,
};
};
export default connect(mapStateToProps)(Main);