one signal setup

This commit is contained in:
Brice Zele 2020-08-17 22:16:31 +01:00
parent 3fd1528ae7
commit 2f3ddf5a2f
6 changed files with 92 additions and 100 deletions

15
App.js
View File

@ -9,7 +9,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { ActionSheetProvider, connectActionSheet } from '@expo/react-native-action-sheet' import { ActionSheetProvider, connectActionSheet } from '@expo/react-native-action-sheet'
import { Platform, StyleSheet, Text, View, YellowBox, AsyncStorage } from 'react-native'; import { Platform, StyleSheet, Text, View, YellowBox, AsyncStorage } from 'react-native';
import { createSwitchNavigator, createStackNavigator, createDrawerNavigator, createAppContainer, createBottomTabNavigator, HeaderBackButton } from 'react-navigation'; import { createSwitchNavigator, createStackNavigator, createDrawerNavigator, createAppContainer, createBottomTabNavigator, HeaderBackButton, withNavigation } from 'react-navigation';
import OneSignal from 'react-native-onesignal'; import OneSignal from 'react-native-onesignal';
import _ from 'lodash'; import _ from 'lodash';
import Connect from "./screens/login/Connect"; import Connect from "./screens/login/Connect";
@ -352,6 +352,8 @@ class App extends React.Component {
constructor(properties) { constructor(properties) {
super(properties); super(properties);
console.log("APP PROPS", this.props);
//Remove this method to stop OneSignal Debugging //Remove this method to stop OneSignal Debugging
OneSignal.setLogLevel(6, 0); OneSignal.setLogLevel(6, 0);
@ -441,11 +443,12 @@ class App extends React.Component {
goToScreen = (routeName, params, isReset = true) => { goToScreen = (routeName, params, isReset = true) => {
const { navigator } = this.refs; const { navigator } = this.refs;
navigator.dispatch({ console.log("APP REFS", this.refs);
type: "Navigation/NAVIGATE", // navigator.dispatch({
routeName, // type: "Navigation/NAVIGATE",
params // routeName,
}); // params
// });
// if (isReset) { // if (isReset) {
// const resetAction = NavigationActions.reset({ // const resetAction = NavigationActions.reset({

View File

@ -139,7 +139,7 @@ class CreateGroupNanoCredit extends Component {
{ {
text: I18n.t("OK"), onPress: () => { text: I18n.t("OK"), onPress: () => {
this.props.createGroupReset(); this.props.createGroupReset();
IlinkEmitter.emit("refreshWallet"); IlinkEmitter.emit("treatNanoGroupDemand");
this.props.navigation.pop(); this.props.navigation.pop();
} }
} }

View File

@ -125,19 +125,13 @@ class DemandValidationGroup extends React.Component {
this.navigation = this.props.navigation this.navigation = this.props.navigation
this.currentLocale = DeviceInfo.getDeviceLocale().includes("fr") ? "fr" : "en-gb"; this.currentLocale = DeviceInfo.getDeviceLocale().includes("fr") ? "fr" : "en-gb";
//moment.locale(this.currentLocale); //moment.locale(this.currentLocale);
IlinkEmitter.on('treatNanoGroupDemand', this.refreshData);
}; };
componentDidMount() { componentDidMount() {
const { routeName } = this.navigation.state const { routeName } = this.navigation.state
this.setState({ position: routeName === "demandeValidationGroupe" ? 0 : 1, isDataSubmit: true }); this.setState({ position: routeName === "demandeValidationGroupe" ? 0 : 1, isDataSubmit: true });
this.refreshData();
this.animateSlidingUp(false) this.animateSlidingUp(false)
this.props.navigation.addListener("didFocus", () => {
this.refreshData(false)
console.warn("loading")
})
} }
@ -302,8 +296,8 @@ class DemandValidationGroup extends React.Component {
</ActionButton>) </ActionButton>)
} }
refreshData(autoref = true) { refreshData() {
this.props.getNanoCreditDemandsAction(this.state.user.id);
} }
render() { render() {

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { StyleSheet, View, Text, Alert, Platform, ProgressBarAndroid } from 'react-native' import { StyleSheet, View, Text, Alert, Platform, ScrollView, ProgressBarAndroid } from 'react-native'
import CardView from 'react-native-cardview' import CardView from 'react-native-cardview'
import Button from 'apsl-react-native-button' import Button from 'apsl-react-native-button'
import { responsiveHeight, responsiveWidth } from 'react-native-responsive-dimensions' import { responsiveHeight, responsiveWidth } from 'react-native-responsive-dimensions'
@ -142,38 +142,13 @@ class DemandGroupNanoCreditDetail extends Component {
if (errorTreatDemand !== null) { if (errorTreatDemand !== null) {
if (typeof errorTreatDemand.data !== 'undefined') { if (typeof errorTreatDemand.data !== 'undefined') {
if (errorTreatDemand.status === 426) {
Alert.alert(
I18n.t("ERROR_TREATMENT_DEMAND"),
errorTreatDemand.data.error,
[{
text: I18n.t('CANCEL_LABEL'),
onPress: () => { },
style: 'cancel'
},
{
text: I18n.t("OK"), onPress: () => {
setTimeout(() => {
this.setState({
displayAmountModifyDialog: true
});
}, 10);
this.props.creditDemandResetReducer();
this.props.creditCancelResetReducer();
}
}],
{ cancelable: false }
);
}
else {
Alert.alert( Alert.alert(
I18n.t("ERROR_TREATMENT_DEMAND"), I18n.t("ERROR_TREATMENT_DEMAND"),
errorTreatDemand.data.error, errorTreatDemand.data.error,
[ [
{ {
text: I18n.t("OK"), onPress: () => { text: I18n.t("OK"), onPress: () => {
this.props.creditDemandResetReducer(); this.props.treatDemandGroupReset();
this.props.creditCancelResetReducer();
} }
} }
], ],
@ -181,47 +156,14 @@ class DemandGroupNanoCreditDetail extends Component {
); );
} }
} }
}
if (errorCancelDemand !== null) {
if (typeof errorCancelDemand.data !== 'undefined') {
Alert.alert(
I18n.t("ERROR_TREATMENT_DEMAND"),
errorCancelDemand.data.error,
[
{
text: I18n.t("OK"), onPress: () => {
this.props.creditCancelResetReducer();
this.props.creditDemandResetReducer();
}
}
],
{ cancelable: false }
)
}
}
if (resultTreatDemand !== null) { if (resultTreatDemand !== null) {
console.log("resultTreatDemand", resultTreatDemand); console.log("resultTreatDemand", resultTreatDemand);
if (resultTreatDemand.status === 200) { if (resultTreatDemand.status === 200) {
this.displayToast(resultTreatDemand.response); this.displayToast(resultTreatDemand.response);
this.props.navigation.goBack(); this.props.navigation.goBack();
this.props.navigation.state.params.onGoBack(); IlinkEmitter.emit('treatNanoGroupDemand');
this.props.creditCancelResetReducer(); this.props.treatDemandGroupReset();
this.props.creditDemandResetReducer();
}
}
if (resultCancelDemand !== null) {
console.log("resultCancelDemand", resultCancelDemand);
if (resultCancelDemand.status === 200) {
this.displayToast(resultCancelDemand.response);
this.props.navigation.goBack();
this.props.navigation.state.params.onGoBack();
this.props.creditCancelResetReducer();
this.props.creditDemandResetReducer();
} }
} }
@ -230,7 +172,7 @@ class DemandGroupNanoCreditDetail extends Component {
renderLabelState = (state) => { renderLabelState = (state) => {
if (state === 0) if (state === 0)
return I18n.t('NO_TREAT') return I18n.t('NO_TREAT')
else if (statut === 1) else if (state === 1)
return I18n.t('TREAT') return I18n.t('TREAT')
else else
return I18n.t('REFUSED') return I18n.t('REFUSED')
@ -359,8 +301,9 @@ class DemandGroupNanoCreditDetail extends Component {
renderDetail = () => { renderDetail = () => {
const resultGetUniqueDemand = this.props.resultGetUniqueDemand; const {resultGetUniqueDemand} = this.props;
console.log("resultGetUniqueDemand", resultGetUniqueDemand); let ago = moment.tz(resultGetUniqueDemand.response.date_creation, 'Etc/GMT+0').format();
ago = moment(ago)
return (<View style={styles.container}> return (<View style={styles.container}>
<CardView <CardView
style={styles.cardcontainer1} style={styles.cardcontainer1}
@ -371,7 +314,7 @@ class DemandGroupNanoCreditDetail extends Component {
color: 'black', color: 'black',
marginLeft: responsiveWidth(5) marginLeft: responsiveWidth(5)
}}> }}>
{I18n.t('DEMAND_INFO')} {resultGetUniqueDemand.response.nom}
</Text> </Text>
<View style={{ <View style={{
flexDirection: 'row', flexDirection: 'row',
@ -384,7 +327,7 @@ class DemandGroupNanoCreditDetail extends Component {
marginLeft: 20 marginLeft: 20
}} }}
/> />
<Text style={styles.simpleuser}>{`${I18n.t('CREATOR')} ${resultGetUniqueDemand.response.createur}`}</Text> <Text style={styles.simpleuser}>{`${I18n.t('CREATOR')}: ${resultGetUniqueDemand.response.createur}`}</Text>
</View> </View>
<View style={{ <View style={{
flexDirection: 'row', flexDirection: 'row',
@ -397,11 +340,56 @@ class DemandGroupNanoCreditDetail extends Component {
marginLeft: 20 marginLeft: 20
}} }}
/> />
<Text style={styles.simpleuser}>{`${I18n.t('COUNTRY')} ${resultGetUniqueDemand.response.country}`}</Text> <Text style={styles.simpleuser}>{`${I18n.t('COUNTRY')}: ${resultGetUniqueDemand.response.country}`}</Text>
</View> </View>
</CardView> </CardView>
{/* <CardView style={styles.cardcontainer}>
<Text style={{ <CardView
style={styles.cardcontainer}
>
<View style={{
flexDirection: 'row',
justifyContent: 'flex-start'
}}>
<Icon name='account-multiple'
size={28}
color={theme.accent}
style={{
marginLeft: 20
}}
/>
<Text style={styles.simpleuser}>{`SPONSOR 1: ${resultGetUniqueDemand.response.sponsor1}`}</Text>
</View>
<View style={{
flexDirection: 'row',
justifyContent: 'flex-start'
}}>
<Icon name='account-multiple'
size={28}
color={theme.accent}
style={{
marginLeft: 20
}}
/>
<Text style={styles.simpleuser}>{`SPONSOR 2: ${resultGetUniqueDemand.response.sponsor2}`}</Text>
</View>
<View style={{
flexDirection: 'row',
justifyContent: 'flex-start'
}}>
<Icon name='account-multiple'
size={28}
color={theme.accent}
style={{
marginLeft: 20
}}
/>
<Text style={styles.simpleuser}>{`SPONSOR 3: ${resultGetUniqueDemand.response.sponsor3}`}</Text>
</View>
</CardView>
<CardView style={styles.cardcontainer}>
{/* <Text style={{
fontSize: 17, fontSize: 17,
fontWeight: 'bold', fontWeight: 'bold',
color: 'black', color: 'black',
@ -419,45 +407,45 @@ class DemandGroupNanoCreditDetail extends Component {
}} }}
/> />
<Text style={styles.simpleuser}>{this.item.code_parrain}</Text> <Text style={styles.simpleuser}>{this.item.code_parrain}</Text>
</View> </View> */}
<View style={{ <View style={{
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'flex-start' justifyContent: 'flex-start'
}}> }}>
<Icon name='md-code-working' <Icon name='code-tags'
size={28} size={28}
color={theme.accent} color={theme.accent}
style={{ style={{
marginLeft: 20 marginLeft: 20
}} }}
/> />
<Text style={styles.simpleuser}>{this.item.reseau}</Text> <Text style={styles.simpleuser}>{resultGetUniqueDemand.response.code_groupe}</Text>
</View> </View>
<View style={{ <View style={{
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'flex-start' justifyContent: 'flex-start'
}}> }}>
<Icon name='md-wallet' <Icon name='cash'
size={28} size={28}
color={theme.accent} color={theme.accent}
style={{ style={{
marginLeft: 20 marginLeft: 20
}} }}
/> />
<Text style={styles.simpleuser}>{this.item.montant}</Text> <Text style={styles.simpleuser}>{`${I18n.t('LIMITE_GROUP')}: ${resultGetUniqueDemand.response.limite_credit} ${resultGetUniqueDemand.response.currency_code}`}</Text>
</View> </View>
<View style={{ <View style={{
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'flex-start' justifyContent: 'flex-start'
}}> }}>
<Icon name='md-calendar' <Icon name='calendar'
size={28} size={28}
color={theme.accent} color={theme.accent}
style={{ style={{
marginLeft: 20 marginLeft: 20
}} }}
/> />
<Text style={styles.simpleuser}>{ago.format(" Do MMMM YYYY à HH:mm")}</Text> <Text style={styles.simpleuser}>{`${I18n.t('CREATION_DATE')}: ${ago.format(" Do MMMM YYYY à HH:mm")}`}</Text>
</View> </View>
<View style={{ <View style={{
flexDirection: 'row', flexDirection: 'row',
@ -465,7 +453,7 @@ class DemandGroupNanoCreditDetail extends Component {
marginRight: 20, marginRight: 20,
justifyContent: 'flex-start' justifyContent: 'flex-start'
}}> }}>
<Icon name='md-time' <Icon name='update'
size={28} size={28}
color={theme.accent} color={theme.accent}
/> />
@ -476,22 +464,24 @@ class DemandGroupNanoCreditDetail extends Component {
}}>{ago.fromNow()}</Text> }}>{ago.fromNow()}</Text>
</View> </View>
</CardView> */} </CardView>
{this.renderBtn()} {this.renderBtn()}
</View>); </View>);
} }
render() { render() {
console.log("DEMAND GROUP PROPS", this.props); console.log("DEMAND GROUP PROPS", this.props);
//let ago = moment.tz(this.item.date_creation, 'Etc/GMT+0').format();
//ago = moment(ago)
return ( return (
<> <>
{(this.state.triggerTreatmentClick || this.state.triggerCancelClick) && this.renderAlertErrorTreatOrCancelDemand()} {(this.state.triggerTreatmentClick || this.state.triggerCancelClick) && this.renderAlertErrorTreatOrCancelDemand()}
{ {
this.props.loadingGetUniqueDemand ? this.props.loadingGetUniqueDemand ?
this.renderLoader() : this.renderLoader() :
this.renderDetail() this.props.resultGetUniqueDemand != null ?
this.renderDetail() :
null
} }
</> </>
); );

View File

@ -331,6 +331,10 @@
"SEND": "Send", "SEND": "Send",
"CHANGE_INFORMATION": "Change my information", "CHANGE_INFORMATION": "Change my information",
"VALIDATE": "Validate", "VALIDATE": "Validate",
"NO_VALIDATE": "Invalid",
"VALIDATION": "validation",
"VALIDATIONS": "validations",
"LIMITE_GROUP": "Credit limit",
"CONNECT": "Connection", "CONNECT": "Connection",
"TEXT_BIG_CREATE_1": "Register as a User", "TEXT_BIG_CREATE_1": "Register as a User",
"TEXT_SUBTITLE_CREATE_1": "Fill in your personal information", "TEXT_SUBTITLE_CREATE_1": "Fill in your personal information",

View File

@ -337,6 +337,7 @@
"NO_VALIDATE": "Non validé", "NO_VALIDATE": "Non validé",
"VALIDATION": "validation", "VALIDATION": "validation",
"VALIDATIONS": "validations", "VALIDATIONS": "validations",
"LIMITE_GROUP": "Limite crédit",
"SELECT_YOUR_WALLET": "Selectionner un wallet", "SELECT_YOUR_WALLET": "Selectionner un wallet",
"CONNECT": "Connexion", "CONNECT": "Connexion",
"TEXT_BIG_CREATE_1": "Inscrivez vous en tant qu'Utilisateur", "TEXT_BIG_CREATE_1": "Inscrivez vous en tant qu'Utilisateur",