diff --git a/app/assets/img/icon3-a-supprimer.png b/app/assets/img/icon3-a-supprimer.png new file mode 100644 index 0000000..a6e671f Binary files /dev/null and b/app/assets/img/icon3-a-supprimer.png differ diff --git a/app/assets/img/icon3.png b/app/assets/img/icon3.png index a6e671f..02e3763 100644 Binary files a/app/assets/img/icon3.png and b/app/assets/img/icon3.png differ diff --git a/app/assets/img/logo.png b/app/assets/img/logo.png index 861148a..f1b5dc8 100644 Binary files a/app/assets/img/logo.png and b/app/assets/img/logo.png differ diff --git a/app/assets/img/png/wallet.png b/app/assets/img/png/wallet.png index cb1cb71..03dcffd 100644 Binary files a/app/assets/img/png/wallet.png and b/app/assets/img/png/wallet.png differ diff --git a/app/screens/login/CreateUserStep.js b/app/screens/login/CreateUserStep.js index bbb7461..81025c1 100644 --- a/app/screens/login/CreateUserStep.js +++ b/app/screens/login/CreateUserStep.js @@ -577,7 +577,7 @@ class CreateUserStep extends Component { renderRequiredTaxesDropdown = (item, index) => { return ( <> - + {/* - + */} { item.measurement_unit !== "forfait" && <> @@ -1360,7 +1360,7 @@ handleTaxSlection = (selectedTax) => { { this.ProprierteTypeAnim = comp }} > - { }}> { return value }} - //value={item.name} labelExtractor={(value) => { return value.name }} - onChangeText={this.handleTaxSlection} - // onChangeText={(value) => { - - // let tax_units_count = this.state.required_taxes; - // if (value === "") - // tax_units_count[index].tax_units_count = null; - // else - // tax_units_count[index].tax_units_count = value; - // this.setState({required_taxes: tax_units_count}); - // }} - - + onChangeText={this.handleTaxSlection} /> - + */} ) : ( @@ -1921,6 +1908,7 @@ handleTaxSlection = (selectedTax) => { checkUserGeolocated() { let {myPosition, textaddress, place, indicatif, user, network, phone, phoneTransaction} = this.state; this.setState({isLoading: true}); + console.log("this.state=========>>>>>>>",this.state) if (this.state.isActif) { let taxes_to_send = []; @@ -2233,7 +2221,8 @@ handleTaxSlection = (selectedTax) => { } else { createGeolocatedAccount(data).then((result) => { - console.log(result); + console.log('resulta==========>>>>>>>',result); + console.log('datass==========>>>>>>>',data); if (result.success !== undefined && result.success === 1) { const message = result.category === 'super' ? I18n.t("HYPERVISOR_MUST_VALIDATE_SUPERVISOR") : I18n.t("ACCOUNT_SUCCESSFULL_CREATED") diff --git a/app/screens/login/createAccount.js b/app/screens/login/createAccount.js index 6613aa7..fbc6850 100644 --- a/app/screens/login/createAccount.js +++ b/app/screens/login/createAccount.js @@ -1,765 +1,914 @@ +import Button from 'apsl-react-native-button'; +import _ from 'lodash'; import React, {Component} from 'react'; import { - StyleSheet, - Text, - View, - Image, - ScrollView, - Alert, - BackHandler, - Platform, - ProgressBarAndroid, ActivityIndicator + ActivityIndicator, + Alert, + BackHandler, + Platform, + ProgressBarAndroid, + ScrollView, + StyleSheet, + Text, + View, } from 'react-native'; -import PropTypes from 'prop-types'; +import * as Animatable from 'react-native-animatable'; +import I18n from 'react-native-i18n'; +import {Dropdown} from 'react-native-material-dropdown-v2'; +import { + responsiveHeight, + responsiveWidth, +} from 'react-native-responsive-dimensions'; +import {Fumi} from 'react-native-textinput-effects'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import Icon from 'react-native-vector-icons/MaterialIcons'; -import {responsiveHeight, responsiveWidth, responsiveFontSize} from 'react-native-responsive-dimensions'; -import {Fumi, Kaede} from 'react-native-textinput-effects' -import * as Animatable from 'react-native-animatable' -import Button from 'apsl-react-native-button' -import {categoryChild, getCodeInformation, getSupervisorInfoCode} from './../../webservice/AuthApi' +import {supervisorCode} from '../../webservice/IlinkConstants'; +import {getData, storeData} from '../../webservice/persistences/StorageService'; +import { + categoryChild, + getCodeInformation, + getSupervisorInfoCode, +} from './../../webservice/AuthApi'; -let theme = require('./../../utils/theme.json') -let route = require('./../../route.json') -import I18n from 'react-native-i18n'; -import _ from "lodash"; -import {getData, storeData} from "../../webservice/persistences/StorageService"; -import {supervisorCode} from "../../webservice/IlinkConstants"; +let theme = require('./../../utils/theme.json'); +let route = require('./../../route.json'); + +const CIVILITY_DATA = [ + {label: 'Monsieur', value: 1}, + {label: 'Madame', value: 2}, + {label: 'Mademoiselle', value: 3}, +]; + +const NATIONALITY_DATA = [{label: 'Cameroun', value: 1}]; export default class CreateAccount extends Component { - static navigatorStyle = { - drawUnderNavBar: true, - navBarHidden: true, - drawUnderStatusBar: false, - statusBarHidden: true, - statusBarTextColorScheme: 'light', + static navigatorStyle = { + drawUnderNavBar: true, + navBarHidden: true, + drawUnderStatusBar: false, + statusBarHidden: true, + statusBarTextColorScheme: 'light', + }; + + static options(passProps) { + return { + topBar: { + visible: false, + enabled: false, + drawBehind: true, + }, + statusBar: { + drawBehind: true, + enabled: false, + }, }; + } - static options(passProps) { - return { - topBar: { - visible: false, - enabled: false, - drawBehind: true, + constructor(props) { + super(props); + const {navigation} = this.props; + this.type = navigation.getParam('type', 0); + this.state = this.initState(); + } + initState() { + return { + password: null, + enterPhone: null, + nationalityAnim: null, + civiliteAnim: null, + nameanim: null, + surnameanim: null, + passwordanim: null, + confirmpassanim: null, + isLoging: false, + snackVisible: false, + snackText: '', + user: {category: this.type === 0 ? 'user' : 'geolocated'}, + displayFirstStep: true, + displaySecondStep: false, + showAlertIfIsOffline: this.type === 1, + isRegisterOffline: false, + displayLoader: false, + codeSupervisorsData: null, + codeSupervisorData: null, + }; + } + + componentDidMount() { + if (this.state.showAlertIfIsOffline) { + Alert.alert( + I18n.t('REGISTER_OPTIONS'), + I18n.t('WOULD_YOU_WANT_TO_REGISTER_OFFLINE'), + [ + { + text: I18n.t('YES'), + onPress: () => { + this.setState({showAlertIfIsOffline: false}); }, - statusBar: { - drawBehind: true, - enabled: false, - } - } + }, + { + text: I18n.t('NO'), + onPress: () => { + this.setState({ + isRegisterOffline: true, + showAlertIfIsOffline: false, + }); + }, + }, + ], + {cancelable: false}, + ); } + } - constructor(props) { - super(props); - const {navigation} = this.props; - this.type = navigation.getParam('type', 0); - this.state = this.initState(); + renderCodeParrainField() { + return ( + + {this.state.displayLoader && this.renderLoader()} + + this.props.navigation.pop()} + /> + + {I18n.t('TEXT_BIG_CREATE_AGENT_1')} + + + {I18n.t('ENTER_SPONSOR_CODE')} + { + this.memberanim = comp; + }}> + { + let use = this.state.user; + use.member = text; + this.setState({user: use}); + }} + iconSize={20} + style={styles.input}> + - } + + + ); + } - initState() { - return { - password: null, - enterPhone: null, - nameanim: null, - surnameanim: null, - passwordanim: null, - confirmpassanim: null, - isLoging: false, - snackVisible: false, - snackText: '', - user: {category: this.type === 0 ? 'user' : 'geolocated'}, - displayFirstStep: true, - displaySecondStep: false, - showAlertIfIsOffline: this.type === 1, - isRegisterOffline: false, - displayLoader: false, - codeSupervisorsData: null, - codeSupervisorData: null + renderUserGeoAccount() { + return ( + + + this.props.navigation.pop()} + /> + + {I18n.t('TEXT_BIG_CREATE_AGENT_1')} + + + + {I18n.t('TEXT_SUBTITLE_CREATE_1')} + + {/* Champs Civilité */} + { + this.civiliteAnim = comp; + }}> + item.value} + labelExtractor={(item, index) => item.label} + onChangeText={(value, index, data) => { + let user = this.state.user; + user.civility_id = value; + this.setState({user}); + }} + /> + - } - } + {/* Champs Nationalité */} + { + this.nationalityAnim = comp; + }}> + item.value} + labelExtractor={(item, index) => item.label} + onChangeText={(value, index, data) => { + let user = this.state.user; + user.nationalty_id = value; + this.setState({user}); + }} + /> + - componentDidMount() { - if (this.state.showAlertIfIsOffline) { - Alert.alert( - I18n.t("REGISTER_OPTIONS"), - I18n.t('WOULD_YOU_WANT_TO_REGISTER_OFFLINE') - , - [ - { - text: I18n.t("YES"), onPress: () => { - this.setState({showAlertIfIsOffline: false}); - } - }, - { - text: I18n.t("NO"), onPress: () => { - this.setState({isRegisterOffline: true, showAlertIfIsOffline: false}); - } - } - - ], - {cancelable: false} - ); - } - } - - renderCodeParrainField() { - return ( - - {this.state.displayLoader && this.renderLoader()} - - this.props.navigation.pop()} - /> - {I18n.t('TEXT_BIG_CREATE_AGENT_1')} - - {I18n.t('ENTER_SPONSOR_CODE')} - - { - this.memberanim = comp - }}> - { - let use = this.state.user; - use.member = text; - this.setState({user: use}) - }} - - iconSize={20} - style={styles.input} - > - - - - - - - ); - } - - renderUserGeoAccount() { - return ( - - this.props.navigation.pop()} - /> - {I18n.t('TEXT_BIG_CREATE_AGENT_1')} - - {I18n.t('TEXT_SUBTITLE_CREATE_1')} - - { - this.nameanim = comp - }}> - { - let use = this.state.user; - use.lastname = text; - this.setState({user: use}) - }} - value={this.state.user.lastname} - style={styles.input} - > - - - - { - this.surnameanim = comp - }}> - { - let use = this.state.user; - use.address = text; - this.setState({user: use}) - }} - - > - - - { - this.mailanim = comp - }}> - { - let use = this.state.user; - use.email = text; - this.setState({user: use}) - }} - - style={styles.input} - > - - - { - this.passanim = comp - }}> - { - let use = this.state.user; - use.password = text; - this.setState({user: use}) - }} - iconSize={20} - style={styles.input} - > - - - { - this.confirmanim = comp - }}> - { - let use = this.state.user; - use.confirmpass = text; - this.setState({user: use}) - }} - - iconSize={20} - style={styles.input} - > - - - - - ) - - } - - renderUserAccount() { - return ( - - this.props.navigation.pop()} - /> - {I18n.t('TEXT_BIG_CREATE_1')} - - {I18n.t('TEXT_SUBTITLE_CREATE_1')} - { - this.nameanim = comp - }}> - { - let use = this.state.user; - use.lastname = text; - this.setState({user: use}) - }} - iconColor={'#f95a25'} - iconSize={20} - style={styles.input} - > - - - { - this.surnameanim = comp - }}> - { - let use = this.state.user; - use.address = text; - this.setState({user: use}) - }} - - style={styles.input} - > - - - { - this.mailanim = comp - }}> - { - let use = this.state.user; - use.email = text; - this.setState({user: use}) - }} - style={styles.input} - > - - - { - this.passanim = comp - }}> - { - let use = this.state.user; - use.password = text; - this.setState({user: use}) - }} - style={styles.input} - > - - - { - this.confirmanim = comp - }}> - { - let use = this.state.user; - use.confirmpass = text; - this.setState({user: use}) - }} - style={styles.input} - > - - - - - - ) - } - - async _onUserCreateAccount() { - let {user} = this.state; - // console.log(user) - if (user !== undefined) { - if (this.checkOrShake(user.lastname, this.nameanim)) { - if (this.checkOrShake(user.address, this.surnameanim)) { - if (this.checkOrShake(user.email, this.mailanim)) { - if (this.checkOrShake(user.password, this.passanim)) { - if (this.checkOrShake(user.confirmpass, this.confirmanim)) { - if (user.confirmpass === user.password) { - this.props.navigation.push(route.creationstep2, { - type: this.type, - user: user - }); - } else { - this.passanim.shake(800); - this.confirmanim.shake(800); - } - } - } + { + this.nameanim = comp; + }}> + { + let use = this.state.user; + use.lastname = text; + this.setState({user: use}); + }} + value={this.state.user.lastname} + style={styles.input}> + + + { + this.surnameanim = comp; + }}> + { + let use = this.state.user; + use.address = text; + this.setState({user: use}); + }}> + + { + this.mailanim = comp; + }}> + { + let use = this.state.user; + use.email = text; + this.setState({user: use}); + }} + style={styles.input}> + + { + this.passanim = comp; + }}> + { + let use = this.state.user; + use.password = text; + this.setState({user: use}); + }} + iconSize={20} + style={styles.input}> + + { + this.confirmanim = comp; + }}> + { + let use = this.state.user; + use.confirmpass = text; + this.setState({user: use}); + }} + iconSize={20} + style={styles.input}> + + + + ); + } + + renderUserAccount() { + return ( + + + this.props.navigation.pop()} + /> + {I18n.t('TEXT_BIG_CREATE_1')} + + + {I18n.t('TEXT_SUBTITLE_CREATE_1')} + + + { + this.civiliteAnim = comp; + }}> + item.value} + // On affiche le label dans la liste (ex: Monsieur, Madame, ...) + labelExtractor={(item, index) => item.label} + onChangeText={(value, index, data) => { + let user = this.state.user; + user.civility_id = value; // <=== on stocke en integer + this.setState({user}); + }} + /> + + + { + this.nationalityAnim = comp; + }}> + item.value} + labelExtractor={(item, index) => item.label} + onChangeText={(value, index, data) => { + let user = this.state.user; + user.nationalty_id = value; // <=== on stocke en integer + this.setState({user}); + }} + /> + + { + this.nameanim = comp; + }}> + { + let use = this.state.user; + use.lastname = text; + this.setState({user: use}); + }} + iconColor={'#f95a25'} + iconSize={20} + style={styles.input}> + + { + this.surnameanim = comp; + }}> + { + let use = this.state.user; + use.address = text; + this.setState({user: use}); + }} + style={styles.input}> + + { + this.mailanim = comp; + }}> + { + let use = this.state.user; + use.email = text; + this.setState({user: use}); + }} + style={styles.input}> + + { + this.passanim = comp; + }}> + { + let use = this.state.user; + use.password = text; + this.setState({user: use}); + }} + style={styles.input}> + + { + this.confirmanim = comp; + }}> + { + let use = this.state.user; + use.confirmpass = text; + this.setState({user: use}); + }} + style={styles.input}> + + + + + ); + } + + async _onUserCreateAccount() { + let {user} = this.state; + console.log('user=======>>>>>>', user); + if (user !== undefined) { + if (this.checkOrShake(user.civility_id, this.civiliteAnim)) { + // Vérification Nationalité + if (this.checkOrShake(user.nationalty_id, this.nationalityAnim)) { + if (this.checkOrShake(user.lastname, this.nameanim)) { + if (this.checkOrShake(user.address, this.surnameanim)) { + if (this.checkOrShake(user.email, this.mailanim)) { + if (this.checkOrShake(user.password, this.passanim)) { + if (this.checkOrShake(user.confirmpass, this.confirmanim)) { + if (user.confirmpass === user.password) { + this.props.navigation.push(route.creationstep2, { + type: this.type, + user: user, + }); + } else { + this.passanim.shake(800); + this.confirmanim.shake(800); } + } } + } } - } else { - /*this.props.navigator.showSnackbar({ + } + } + } + } else { + /*this.props.navigator.showSnackbar({ text:"impossible de trouvé l'utilisateur" }) console.log(user) */ - } - } + } - checkUserGeolocated() { - let {user} = this.state; - this.setState({isLoging: true}) - if (user !== undefined) { - if (this.checkOrShake(user.lastname, this.nameanim)) { - if (this.checkOrShake(user.address, this.surnameanim)) { - if (this.checkOrShake(user.email, this.mailanim)) { + checkUserGeolocated() { + let {user} = this.state; + // console.log("user=======>>>>>>",user) + // console.log("user=======>>>>>>",user.civility_id) + // console.log("user=======>>>>>>",user.civility_id.length) + this.setState({isLoging: true}); + if (user !== undefined) { + if (this.checkOrShake(user.civility_id, this.civiliteAnim)) { + if (this.checkOrShake(user.nationalty_id, this.nationalityAnim)) { + if (this.checkOrShake(user.lastname, this.nameanim)) { + if (this.checkOrShake(user.address, this.surnameanim)) { + if (this.checkOrShake(user.email, this.mailanim)) { + if (this.state.isRegisterOffline) { + if (!_.isNil(this.state.codeSupervisorData)) { + this.setState({isLoging: false}); + if (this.state.codeSupervisorData.child !== undefined) { + let user = this.state.user; + user.category = this.state.codeSupervisorData.child; + this.setState({user: user}); + } - if (this.state.isRegisterOffline) { - if (!_.isNil(this.state.codeSupervisorData)) { - - this.setState({isLoging: false}); - if (this.state.codeSupervisorData.child !== undefined) { - let user = this.state.user; - user.category = this.state.codeSupervisorData.child; - this.setState({user: user}); - } - - if (this.checkOrShake(user.password, this.passanim)) { - if (this.checkOrShake(user.confirmpass, this.confirmanim)) { - if (user.password === user.confirmpass) { - this.props.navigation.push(route.creationstep2, { - type: this.type, - user: user, - isOffline: this.state.isRegisterOffline, - result: this.state.codeSupervisorData, - - }); - - } else { - this.passanim.shake(800) - this.confirmanim.shake(800) - this.setState({isLoging: false}) - } - } else { - this.setState({isLoging: false}) - } - } else this.setState({isLoging: false}) - - } + if (this.checkOrShake(user.password, this.passanim)) { + if ( + this.checkOrShake(user.confirmpass, this.confirmanim) + ) { + if (user.password === user.confirmpass) { + this.props.navigation.push(route.creationstep2, { + type: this.type, + user: user, + isOffline: this.state.isRegisterOffline, + result: this.state.codeSupervisorData, + }); } else { - categoryChild(user.member).then(async (codes) => { - // console.log("CATEGORY", codes); - if (codes !== undefined && codes !== null && codes.child !== undefined) { - let user = this.state.user; - user.category = codes.child; - this.setState({user: user}); - } - this.setState({isLoging: false}); - if (this.checkOrShake(user.password, this.passanim)) { - if (this.checkOrShake(user.confirmpass, this.confirmanim)) { - if (user.password === user.confirmpass) { - this.props.navigation.push(route.creationstep2, { - type: this.type, - user: user, - isOffline: this.state.isRegisterOffline - }); - - } else { - this.passanim.shake(800) - this.confirmanim.shake(800) - this.setState({isLoging: false}) - } - } else { - this.setState({isLoging: false}) - } - } else this.setState({isLoging: false}) - - }).catch((e) => { - this.setState({isLoging: false}) - }) + this.passanim.shake(800); + this.confirmanim.shake(800); + this.setState({isLoging: false}); } - - - } else this.setState({isLoging: false}) - - } else this.setState({isLoging: false}) - - } else this.setState({isLoging: false}) - - } else { - this.setState({isLoging: false}); - /*this.props.navigator.showSnackbar({ + } else { + this.setState({isLoging: false}); + } + } else this.setState({isLoging: false}); + } + } else { + categoryChild(user.member) + .then(async codes => { + // console.log("CATEGORY", codes); + if ( + codes !== undefined && + codes !== null && + codes.child !== undefined + ) { + let user = this.state.user; + user.category = codes.child; + this.setState({user: user}); + } + this.setState({isLoging: false}); + if (this.checkOrShake(user.password, this.passanim)) { + if ( + this.checkOrShake(user.confirmpass, this.confirmanim) + ) { + if (user.password === user.confirmpass) { + this.props.navigation.push(route.creationstep2, { + type: this.type, + user: user, + isOffline: this.state.isRegisterOffline, + }); + } else { + this.passanim.shake(800); + this.confirmanim.shake(800); + this.setState({isLoging: false}); + } + } else { + this.setState({isLoging: false}); + } + } else this.setState({isLoging: false}); + }) + .catch(e => { + this.setState({isLoging: false}); + }); + } + } else this.setState({isLoging: false}); + } else this.setState({isLoging: false}); + } else this.setState({isLoging: false}); + } else this.setState({isLoging: false}); + } else this.setState({isLoging: false}); + } else { + this.setState({isLoging: false}); + /*this.props.navigator.showSnackbar({ text:"impossible de trouvé la variable user" })*/ - // console.log(user) - } - + // console.log(user) } + } - retreiveSupervisorInfosCode() { - getSupervisorInfoCode().then((result) => { - console.warn("SUPERVISOR INFOS CODE", JSON.stringify(result)); - storeData(supervisorCode, JSON.stringify(result)).then(() => { - this.setState({displayLoader: false}); - }); - }).catch(error => { - //console.log(error); - }) - } - - renderLoader() { - return ( - - {Platform.OS === 'android' - ? - ( - <> - - {I18n.t('LOADING_DOTS')} - - - ) : - <> - - {I18n.t('LOADING_DOTS')} - - } - - ) - } - - retreiveCodeInformation() { - this.setState({isLoging: true}); - const membre = this.state.user.member; - return new Promise(async (resolve, reject) => { - try { - let datas = await getCodeInformation(membre); - resolve(datas); - } catch (e) { - // console.log("Erreur", e); - this.setState({isLoging: false}); - Alert.alert( - I18n.t("UNABLE_TO_CONNECT_TITLE"), - I18n.t('IMPOSSIBLE_TO_CONNECT_INTERNET') - , - [ - { - text: I18n.t("NO"), onPress: () => { - BackHandler.exitApp(); - } - }, - { - text: I18n.t("YES"), onPress: () => { - this.retreiveSupervisorInfosCode(); - this.setState({isLoging: false}); - } - } - - ], - {cancelable: false} - ); - reject(e); - } - + retreiveSupervisorInfosCode() { + getSupervisorInfoCode() + .then(result => { + console.warn('SUPERVISOR INFOS CODE', JSON.stringify(result)); + storeData(supervisorCode, JSON.stringify(result)).then(() => { + this.setState({displayLoader: false}); }); + }) + .catch(error => { + //console.log(error); + }); + } - } + renderLoader() { + return ( + + {Platform.OS === 'android' ? ( + <> + + {I18n.t('LOADING_DOTS')} + + ) : ( + <> + + {I18n.t('LOADING_DOTS')} + + )} + + ); + } - async checkCodeParrain() { - let {user} = this.state; - if (this.checkOrShake(user.member, this.memberanim)) { - this.setState({isLoging: true}); + retreiveCodeInformation() { + this.setState({isLoging: true}); + const membre = this.state.user.member; + return new Promise(async (resolve, reject) => { + try { + let datas = await getCodeInformation(membre); + resolve(datas); + } catch (e) { + // console.log("Erreur", e); + this.setState({isLoging: false}); + Alert.alert( + I18n.t('UNABLE_TO_CONNECT_TITLE'), + I18n.t('IMPOSSIBLE_TO_CONNECT_INTERNET'), + [ + { + text: I18n.t('NO'), + onPress: () => { + BackHandler.exitApp(); + }, + }, + { + text: I18n.t('YES'), + onPress: () => { + this.retreiveSupervisorInfosCode(); + this.setState({isLoging: false}); + }, + }, + ], + {cancelable: false}, + ); + reject(e); + } + }); + } - if (this.state.isRegisterOffline) { - getData(supervisorCode).then(codeSupervisor => { - if (_.isNil(codeSupervisor)) { - Alert.alert( - I18n.t("ERROR_LABEL"), - I18n.t('DATA_NOT_SYNCHRONISED_WITH_SERVER') - , - [ - { - text: I18n.t("NO"), onPress: () => { - BackHandler.exitApp(); - } - }, - { - text: I18n.t("YES"), onPress: () => { - this.setState({displayLoader: true}); - } - } + async checkCodeParrain() { + let {user} = this.state; + if (this.checkOrShake(user.member, this.memberanim)) { + this.setState({isLoging: true}); - ], - {cancelable: false} - ); - } else { + if (this.state.isRegisterOffline) { + getData(supervisorCode).then(codeSupervisor => { + if (_.isNil(codeSupervisor)) { + Alert.alert( + I18n.t('ERROR_LABEL'), + I18n.t('DATA_NOT_SYNCHRONISED_WITH_SERVER'), + [ + { + text: I18n.t('NO'), + onPress: () => { + BackHandler.exitApp(); + }, + }, + { + text: I18n.t('YES'), + onPress: () => { + this.setState({displayLoader: true}); + }, + }, + ], + {cancelable: false}, + ); + } else { + let codeSupervisorsData = JSON.parse(codeSupervisor); + let codeSupervisors = Object.keys(codeSupervisorsData); + this.setState({codeSupervisorsData}); - let codeSupervisorsData = JSON.parse(codeSupervisor); - let codeSupervisors = Object.keys(codeSupervisorsData); - this.setState({codeSupervisorsData}); - - if (!codeSupervisors.includes(user.member)) { - Alert.alert(I18n.t("ERROR_LABEL"), I18n.t('CODE_AGENT_NOT_EXIST') - , [{ - text: 'OK', onPress: () => { - this.setState({isLoging: false}); - //this.props.navigation.goBack(); - } - }], {cancelable: false}); - } else { - this.setState({isLoging: false}); - let resultInfosCode = codeSupervisorsData[user.member]; - this.setState({codeSupervisorData: resultInfosCode}); - - if (resultInfosCode.network.is_companies_network === "1" && resultInfosCode.child == "geolocated") { - this.props.navigation.push(route.createUserStep, { - type: this.type, - user: this.state.user, - result: resultInfosCode, - isActif: true, - isOffline: this.state.isRegisterOffline - }); - } else { - this.setState({ - displayFirstStep: false, - displaySecondStep: true, - isLoging: false, - }); - } - } - } - }); + if (!codeSupervisors.includes(user.member)) { + Alert.alert( + I18n.t('ERROR_LABEL'), + I18n.t('CODE_AGENT_NOT_EXIST'), + [ + { + text: 'OK', + onPress: () => { + this.setState({isLoging: false}); + //this.props.navigation.goBack(); + }, + }, + ], + {cancelable: false}, + ); } else { - let result = {}; - try { - result = await this.retreiveCodeInformation(); - // console.log("RESULTAT ", result); - if (_.isNil(result.error)) { - let resultInfosCode = await this.retreiveCodeInformation(); - if (_.isNil(resultInfosCode.error)) { + this.setState({isLoging: false}); + let resultInfosCode = codeSupervisorsData[user.member]; + this.setState({codeSupervisorData: resultInfosCode}); - this.setState({isLoging: false}); - if (resultInfosCode.network.is_companies_network === "1" && resultInfosCode.child == "geolocated") { - this.props.navigation.push(route.createUserStep, { - type: this.type, - user: this.state.user, - result: resultInfosCode, - isActif: true, - isOffline: this.state.isRegisterOffline - }); - } else { - this.setState({ - displayFirstStep: false, - displaySecondStep: true, - isLoging: false - }); - } - - } else { - Alert.alert(I18n.t("ERROR_LABEL"), "" - , [{ - text: 'OK', onPress: () => { - } - }], {cancelable: false}); - } - } else { - if (result.error !== undefined) { - switch (result.error) { - case -7: - Alert.alert(I18n.t("ERROR_LABEL"), result.error_msg - , [{ - text: 'OK', onPress: () => { - this.setState({isLoging: false}); - //this.props.navigation.goBack(); - } - }], {cancelable: false}) - break; - default: - Alert.alert(I18n.t("ERROR_LABEL"), "" - , [{ - text: 'OK', onPress: () => { - this.setState({isLoging: false}); - //this.props.navigation.goBack(); - } - }], {cancelable: false}); - } - this.setState({isLoading: false}) - } - } - - } catch (e) { - result = false - } + if ( + resultInfosCode.network.is_companies_network === '1' && + resultInfosCode.child == 'geolocated' + ) { + this.props.navigation.push(route.createUserStep, { + type: this.type, + user: this.state.user, + result: resultInfosCode, + isActif: true, + isOffline: this.state.isRegisterOffline, + }); + } else { + this.setState({ + displayFirstStep: false, + displaySecondStep: true, + isLoging: false, + }); + } } - - } else this.setState({isLoging: false}); - } - - checkOrShake(champ, view) { - let res = false; - if (champ !== undefined && champ.length > 0) { - res = true; - } else { - view.shake(800) + } + }); + } else { + let result = {}; + try { + result = await this.retreiveCodeInformation(); + // console.log("RESULTAT ", result); + if (_.isNil(result.error)) { + let resultInfosCode = await this.retreiveCodeInformation(); + if (_.isNil(resultInfosCode.error)) { + this.setState({isLoging: false}); + if ( + resultInfosCode.network.is_companies_network === '1' && + resultInfosCode.child == 'geolocated' + ) { + this.props.navigation.push(route.createUserStep, { + type: this.type, + user: this.state.user, + result: resultInfosCode, + isActif: true, + isOffline: this.state.isRegisterOffline, + }); + } else { + this.setState({ + displayFirstStep: false, + displaySecondStep: true, + isLoging: false, + }); + } + } else { + Alert.alert( + I18n.t('ERROR_LABEL'), + '', + [ + { + text: 'OK', + onPress: () => {}, + }, + ], + {cancelable: false}, + ); + } + } else { + if (result.error !== undefined) { + switch (result.error) { + case -7: + Alert.alert( + I18n.t('ERROR_LABEL'), + result.error_msg, + [ + { + text: 'OK', + onPress: () => { + this.setState({isLoging: false}); + //this.props.navigation.goBack(); + }, + }, + ], + {cancelable: false}, + ); + break; + default: + Alert.alert( + I18n.t('ERROR_LABEL'), + '', + [ + { + text: 'OK', + onPress: () => { + this.setState({isLoging: false}); + //this.props.navigation.goBack(); + }, + }, + ], + {cancelable: false}, + ); + } + this.setState({isLoading: false}); + } + } + } catch (e) { + result = false; } - return res; - } - - render() { - return this.type === 1 ? - this.state.displayFirstStep ? - this.renderCodeParrainField() - : this.renderUserGeoAccount() - : this.renderUserAccount() + } + } else this.setState({isLoging: false}); + } + checkOrShake(champ, view) { + let res = false; + if ( + (champ !== undefined && champ.length > 0) || + typeof champ === 'number' + ) { + res = true; + } else { + view.shake(800); } + return res; + } + + render() { + return this.type === 1 + ? this.state.displayFirstStep + ? this.renderCodeParrainField() + : this.renderUserGeoAccount() + : this.renderUserAccount(); + } } const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: theme.primaryDark, - }, - textbtnvalide: { - color: 'white', - fontWeight: 'bold' - }, - bigtitle: { - color: 'white', - fontSize: 20, - flex: 1, - fontWeight: 'bold', - textAlign: 'center', - margin: 20, - }, - subbigtitle: { - color: 'white', - fontSize: 17, - textAlign: 'center', - margin: 5, - }, - btnvalide: { - marginTop: 20, - marginLeft: 20, - marginRight: 20, - borderColor: 'transparent', - backgroundColor: theme.accentLight, - height: 52 - }, - input: { - height: 60, - marginTop: responsiveHeight(2), - marginLeft: responsiveWidth(5), - marginRight: responsiveWidth(5), - borderRadius: 5, - } + container: { + flex: 1, + backgroundColor: theme.primaryDark, + }, + textbtnvalide: { + color: 'white', + fontWeight: 'bold', + }, + bigtitle: { + color: 'white', + fontSize: 20, + flex: 1, + fontWeight: 'bold', + textAlign: 'center', + margin: 20, + }, + subbigtitle: { + color: 'white', + fontSize: 17, + textAlign: 'center', + margin: 5, + }, + btnvalide: { + marginTop: 20, + marginLeft: 20, + marginRight: 20, + borderColor: 'transparent', + backgroundColor: theme.accentLight, + height: 52, + }, + input: { + height: 60, + marginTop: responsiveHeight(2), + marginLeft: responsiveWidth(5), + marginRight: responsiveWidth(5), + borderRadius: 5, + }, + dropdown: { + height: 60, + marginTop: responsiveHeight(2), + marginLeft: responsiveWidth(5), + marginRight: responsiveWidth(5), + borderRadius: 5, + backgroundColor: 'white', + }, }); - diff --git a/app/screens/login/createUserStep2.js b/app/screens/login/createUserStep2.js index e296ae4..02bba32 100644 --- a/app/screens/login/createUserStep2.js +++ b/app/screens/login/createUserStep2.js @@ -1,4 +1,9 @@ -import React, {Component, useState} from 'react'; +import Button from 'apsl-react-native-button'; +import axios from "axios"; +import isEqual from 'lodash/isEqual'; +import isNil from 'lodash/isNil'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; import { Alert, BackHandler, @@ -13,20 +18,22 @@ import { TouchableOpacity, View } from 'react-native'; -import PropTypes from 'prop-types'; -import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; -import {responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions'; -import {Fumi} from 'react-native-textinput-effects' import * as Animatable from 'react-native-animatable'; -import Button from 'apsl-react-native-button'; -import MapView, {Marker} from 'react-native-maps'; -import {Dropdown} from 'react-native-material-dropdown-v2'; -import isEqual from 'lodash/isEqual'; -import isNil from 'lodash/isNil'; -import {getPositionInformation} from './../../webservice/MapService'; -import I18n from 'react-native-i18n' -import {material} from 'react-native-typography'; +import Dialog from "react-native-dialog"; +import Geolocation from 'react-native-geolocation-service'; +import I18n from 'react-native-i18n'; +import MapView, { Marker } from 'react-native-maps'; +import { MaterialDialog } from "react-native-material-dialog"; +import { Dropdown } from 'react-native-material-dropdown-v2'; +import { responsiveHeight, responsiveWidth } from 'react-native-responsive-dimensions'; +import { ProgressDialog } from "react-native-simple-dialogs"; +import { Fumi } from 'react-native-textinput-effects'; +import { material } from 'react-native-typography'; +import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; +import { store } from "../../redux/store"; +import { getDefaultTown } from "../../webservice/AuthApi"; +import { uploadImage } from "../../webservice/IlinkConstants"; import { createGeolocatedAccount, createUserAccount, @@ -35,17 +42,7 @@ import { getListCountriesActive, getTownInformationName } from './../../webservice/AuthApi'; -import {MaterialDialog} from "react-native-material-dialog"; -import Geolocation from 'react-native-geolocation-service'; -import ImagePicker from 'react-native-image-crop-picker'; -import {Color} from "../../config/Color"; -import {FontWeight, Typography} from "../../config/typography"; -import Dialog from "react-native-dialog"; -import {store} from "../../redux/store"; -import axios from "axios"; -import {uploadImage} from "../../webservice/IlinkConstants"; -import {ProgressDialog} from "react-native-simple-dialogs"; -import {getDefaultTown} from "../../webservice/AuthApi"; +import { getPositionInformation } from './../../webservice/MapService'; const GEOLOCATION_OPTIONS = {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000, useSignificantChanges: true}; @@ -313,6 +310,8 @@ export default class CreateUserStep2 extends Component { if (jsonMatch) { countriesData = JSON.parse(jsonMatch[0]); } + }else{ + countriesData = response; } const formattedCountries = countriesData.map(country => ({ diff --git a/app/utils/i18n/ar.json b/app/utils/i18n/ar.json index fe249fe..a17f8a3 100644 --- a/app/utils/i18n/ar.json +++ b/app/utils/i18n/ar.json @@ -46,6 +46,8 @@ "GROUP_MEMBERS": "أعضاء المجموعة", "NAME": "اسم العائلة (الأسماء)", "FIRSTNAME": "الاسم الأول (الأسماء)", + "CIVILITY": "المدينة", + "NATIONALITY": "الجنسية", "ADMIN": "المسؤول", "SUPER_ADMIN": "مشرف سوبر", "GEOLOCATED": "الوكيل الجغرافي المحدد", diff --git a/app/utils/i18n/en.json b/app/utils/i18n/en.json index 81c3619..fccd814 100644 --- a/app/utils/i18n/en.json +++ b/app/utils/i18n/en.json @@ -276,6 +276,8 @@ "IMAGE_TAKE": "Image take", "NAME": "Last name(s)", "FIRSTNAME": "First name(s) ", + "CIVILITY": "Civility", + "NATIONALITY": "Nationality", "NAME_EMETTEUR": "Issuer first name(s)", "EMETTEUR": "Issuer", "FIRSTNAME_EMETTEUR": "Issuer last name(s) ", diff --git a/app/utils/i18n/fr.json b/app/utils/i18n/fr.json index f3e6739..1c43727 100644 --- a/app/utils/i18n/fr.json +++ b/app/utils/i18n/fr.json @@ -285,6 +285,8 @@ "IMAGE_TAKE": "Prise d'image", "NAME": "Nom(s)", "FIRSTNAME": "Prénom(s) ", + "CIVILITY": "Civilité", + "NATIONALITY": "Nationalité", "NAME_EMETTEUR": "Nom(s) émetteur", "EMETTEUR": "Emetteur", "FIRSTNAME_EMETTEUR": "Prénom(s) émetteur", diff --git a/app/utils/i18n/zh.json b/app/utils/i18n/zh.json index 779d3a0..3cb3aef 100644 --- a/app/utils/i18n/zh.json +++ b/app/utils/i18n/zh.json @@ -23,6 +23,8 @@ "GROUP_MEMBERS": "小组成员", "NAME": "名", "FIRSTNAME": "名字", + "CIVILITY": "礼貌", + "NATIONALITY": "国籍", "ADDRESS": "地址", "CREDIT": "信用", "EMAIL": "电子邮件",