forked from nsnayp/ets2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppWrap.js
73 lines (60 loc) · 2.12 KB
/
AppWrap.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
//Try something intresting, the one more
// https://expo.io/dashboard/notifications - эта штука реально отправляет нотифы даже закрытые
/*
https://docs.expo.io/versions/v30.0.0/distribution/building-standalone-apps
https://docs.expo.io/versions/latest/guides/push-notifications
https://docs.expo.io/versions/latest/guides/using-fcm
https://expo.io/dashboard/notifications
From work test
*/
import * as React from 'react';
import {Text,AsyncStorage,TouchableOpacity,View} from 'react-native';
import AppAuth from './pages/AppAuth';
import AppNoAuth from './pages/AppNoAuth';
import {connect} from 'react-redux';
import {setCustomerId} from './actions/AppWrapActions';
class AppWrap extends React.Component {
constructor(props) {
super(props)
this.state = {
isGetCustomerId:false
}
AsyncStorage.getItem('customer_id')
.then(value => {
this.props.setCustomerId(value);
this.setState({
isGetCustomerId:true
})
})
.done();
}
render() {
if(this.props.customer_id&&this.props.customer_id>0&&this.state.isGetCustomerId===true){
return(<AppAuth></AppAuth>);
}else if(!this.props.customer_id&&this.state.isGetCustomerId===true){
return(<AppNoAuth></AppNoAuth>);
}else if(this.state.isGetCustomerId===false) {
return null;
}
else{
return (
<TouchableOpacity onPress={()=>{this.props.setCustomerId(null)}}>
<View style={{backgroundColor:'#3F51B5', paddingVertical:16, paddingHorizontal:32, borderRadius:3, elevation:1}}>
<Text style={{color:'#fff', textAlign:'center'}}>Выйти {this.props.customer_id}</Text>
</View>
</TouchableOpacity>
);
}
}
}
const mapStateToProps = state => {
return {
customer_id : state.appwrap.customer_id,
}
}
const mapDispatchToProps = (dispatch, payload) => {
return{
setCustomerId: (payload) => dispatch(setCustomerId(payload))
}
}
export default connect(mapStateToProps, mapDispatchToProps)(AppWrap)