From 5bfad5f0253e145f055dca90a2d165b98e3a83c1 Mon Sep 17 00:00:00 2001 From: Brice Zele Date: Sat, 5 Dec 2020 18:14:33 +0100 Subject: [PATCH] Correction de bugs --- redux/actions/EnvoieUserType.js | 103 +- .../reducers/EnvoieUserWalletToCashReducer.js | 61 +- screens/account/UpdateInformations.js | 161 +- screens/history-request/MyHistory.js | 5 +- .../ModifyIdentificationUser.js | 1189 ++++++------- screens/wallet/WalletOptionSelect.js | 3 +- .../wallet/agent/EnvoiCashVersCashAgent.js | 1514 +++++++++-------- utils/i18n/fr.json | 2 +- 8 files changed, 1598 insertions(+), 1440 deletions(-) diff --git a/redux/actions/EnvoieUserType.js b/redux/actions/EnvoieUserType.js index 2c32c5aa..49fad49b 100644 --- a/redux/actions/EnvoieUserType.js +++ b/redux/actions/EnvoieUserType.js @@ -1,125 +1,144 @@ import { - ENVOIE_WALLET_TO_WALLET_USER_PENDING, ENVOIE_WALLET_TO_WALLET_USER_SUCCESS, ENVOIE_WALLET_TO_WALLET_USER_ERROR, ENVOIE_WALLET_TO_WALLET_USER_RESET, ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_ERROR, - ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_PENDING, ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_SUCCESS, ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_RESET, ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_PENDING, ENVOIE_WALLET_TO_CASH_USER_SUCCESS, ENVOIE_WALLET_TO_CASH_USER_ERROR, ENVOIE_WALLET_TO_CASH_USER_RESET, - ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_SUCCESS, ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_ERROR, ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_RESET, - ENVOIE_WALLET_TO_CARD_USER_PENDING, ENVOIE_WALLET_TO_CARD_USER_SUCCESS, ENVOIE_WALLET_TO_CARD_USER_ERROR, ENVOIE_WALLET_TO_CARD_USER_RESET, - ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_PENDING, ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_SUCCESS, ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_ERROR, ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_RESET + ENVOIE_WALLET_TO_CARD_USER_ERROR, + ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_ERROR, + ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_PENDING, + ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_RESET, + ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_SUCCESS, + ENVOIE_WALLET_TO_CARD_USER_PENDING, + ENVOIE_WALLET_TO_CARD_USER_RESET, + ENVOIE_WALLET_TO_CARD_USER_SUCCESS, + ENVOIE_WALLET_TO_CASH_USER_ERROR, + ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_ERROR, + ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_PENDING, + ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_RESET, + ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_SUCCESS, + ENVOIE_WALLET_TO_CASH_USER_PENDING, + ENVOIE_WALLET_TO_CASH_USER_RESET, + ENVOIE_WALLET_TO_CASH_USER_SUCCESS, + ENVOIE_WALLET_TO_WALLET_USER_ERROR, + ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_ERROR, + ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_PENDING, + ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_RESET, + ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_SUCCESS, + ENVOIE_WALLET_TO_WALLET_USER_PENDING, + ENVOIE_WALLET_TO_WALLET_USER_RESET, + ENVOIE_WALLET_TO_WALLET_USER_SUCCESS } from "../types/EnvoieUserType"; export const fetchEnvoieUserWalletToWalletPending = () => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_PENDING + type: ENVOIE_WALLET_TO_WALLET_USER_PENDING }); export const fetchEnvoieUserWalletToWalletSuccess = (res) => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_SUCCESS, - result: res, + type: ENVOIE_WALLET_TO_WALLET_USER_SUCCESS, + result: res, }); export const fetchEnvoieUserWalletToWalletError = (error) => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_ERROR, - result: error + type: ENVOIE_WALLET_TO_WALLET_USER_ERROR, + result: error }); export const fetchEnvoieUserWalletToWalletReset = (error) => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_RESET + type: ENVOIE_WALLET_TO_WALLET_USER_RESET }); /****************/ export const fetchEnvoieUserWalletToWalleGetCommissiontPending = () => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_PENDING + type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_PENDING }); export const fetchEnvoieUserWalletToWalletGetCommissionSuccess = (res) => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_SUCCESS, - result: res, + type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_SUCCESS, + result: res, }); export const fetchEnvoieUserWalletToWalletGetCommissionError = (error) => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_ERROR, - result: error + type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_ERROR, + result: error }); export const fetchEnvoieUserWalletToWalleGetCommissiontReset = (error) => ({ - type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_RESET + type: ENVOIE_WALLET_TO_WALLET_USER_GET_COMMISSION_RESET }); /*--------------------------------------------------------------------*/ export const fetchEnvoieUserWalletToCashPending = () => ({ - type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_PENDING + type: ENVOIE_WALLET_TO_CASH_USER_PENDING }); export const fetchEnvoieUserWalletToCashSuccess = (res) => ({ - type: ENVOIE_WALLET_TO_CASH_USER_SUCCESS, - result: res, + type: ENVOIE_WALLET_TO_CASH_USER_SUCCESS, + result: res, }); export const fetchEnvoieUserWalletToCashError = (error) => ({ - type: ENVOIE_WALLET_TO_CASH_USER_ERROR, - result: error + type: ENVOIE_WALLET_TO_CASH_USER_ERROR, + result: error }); -export const fetchEnvoieUserWalletToCashReset = (error) => ({ - type: ENVOIE_WALLET_TO_CASH_USER_RESET +export const fetchEnvoieUserWalletToCashReset = () => ({ + type: ENVOIE_WALLET_TO_CASH_USER_RESET }); /****************/ export const fetchEnvoieUserWalletToCashGetCommissiontPending = () => ({ - type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_PENDING + type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_PENDING }); export const fetchEnvoieUserWalletToCashGetCommissionSuccess = (res) => ({ - type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_SUCCESS, - result: res, + type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_SUCCESS, + result: res, }); export const fetchEnvoieUserWalletToCashGetCommissionError = (error) => ({ - type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_ERROR, - result: error + type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_ERROR, + result: error }); export const fetchEnvoieUserWalletToCashGetCommissiontReset = (error) => ({ - type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_RESET + type: ENVOIE_WALLET_TO_CASH_USER_GET_COMMISSION_RESET }); /*--------------------------------------------------------------------*/ export const fetchEnvoieUserWalletToCardPending = () => ({ - type: ENVOIE_WALLET_TO_CARD_USER_PENDING + type: ENVOIE_WALLET_TO_CARD_USER_PENDING }); export const fetchEnvoieUserWalletToCardSuccess = (res) => ({ - type: ENVOIE_WALLET_TO_CARD_USER_SUCCESS, - result: res, + type: ENVOIE_WALLET_TO_CARD_USER_SUCCESS, + result: res, }); export const fetchEnvoieUserWalletToCardError = (error) => ({ - type: ENVOIE_WALLET_TO_CARD_USER_ERROR, - result: error + type: ENVOIE_WALLET_TO_CARD_USER_ERROR, + result: error }); export const fetchEnvoieUserWalletToCardReset = (error) => ({ - type: ENVOIE_WALLET_TO_CARD_USER_RESET + type: ENVOIE_WALLET_TO_CARD_USER_RESET }); /****************/ export const fetchEnvoieUserWalletToCardGetCommissiontPending = () => ({ - type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_PENDING + type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_PENDING }); export const fetchEnvoieUserWalletToCardGetCommissionSuccess = (res) => ({ - type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_SUCCESS, - result: res, + type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_SUCCESS, + result: res, }); export const fetchEnvoieUserWalletToCardGetCommissionError = (error) => ({ - type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_ERROR, - result: error + type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_ERROR, + result: error }); export const fetchEnvoieUserWalletToCardGetCommissiontReset = (error) => ({ - type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_RESET + type: ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_RESET }); \ No newline at end of file diff --git a/redux/reducers/EnvoieUserWalletToCashReducer.js b/redux/reducers/EnvoieUserWalletToCashReducer.js index b92f728c..4675f7b9 100644 --- a/redux/reducers/EnvoieUserWalletToCashReducer.js +++ b/redux/reducers/EnvoieUserWalletToCashReducer.js @@ -1,33 +1,42 @@ -import { ENVOIE_WALLET_TO_CASH_USER_PENDING, ENVOIE_WALLET_TO_CASH_USER_SUCCESS, ENVOIE_WALLET_TO_CASH_USER_ERROR } from "../types/EnvoieUserType"; +import { + ENVOIE_WALLET_TO_CASH_USER_ERROR, + ENVOIE_WALLET_TO_CASH_USER_PENDING, + ENVOIE_WALLET_TO_CASH_USER_RESET, + ENVOIE_WALLET_TO_CASH_USER_SUCCESS +} from "../types/EnvoieUserType"; const initialState = { - loading: false, - result: null, - error: null + loading: false, + result: null, + error: null }; export default (state = initialState, action) => { - switch (action.type) { - case ENVOIE_WALLET_TO_CASH_USER_PENDING: return { - ...state, - loading: true - } - case ENVOIE_WALLET_TO_CASH_USER_SUCCESS: return { - ...state, - loading: false, - result: action.result.data, - error: null - } - case ENVOIE_WALLET_TO_CASH_USER_ERROR: return { - ...state, - loading: false, - result: null, - error: action.result - } - case ENVOIE_WALLET_TO_CASH_USER_PENDING: return initialState; + switch (action.type) { + case ENVOIE_WALLET_TO_CASH_USER_PENDING: + return { + ...state, + loading: true + } + case ENVOIE_WALLET_TO_CASH_USER_SUCCESS: + return { + ...state, + loading: false, + result: action.result.data, + error: null + } + case ENVOIE_WALLET_TO_CASH_USER_ERROR: + return { + ...state, + loading: false, + result: null, + error: action.result + } + case ENVOIE_WALLET_TO_CASH_USER_RESET: + return initialState; - default: { - return state; - } - } + default: { + return state; + } + } }; diff --git a/screens/account/UpdateInformations.js b/screens/account/UpdateInformations.js index 6f28c085..081a4bb9 100644 --- a/screens/account/UpdateInformations.js +++ b/screens/account/UpdateInformations.js @@ -1,21 +1,21 @@ -import React,{Component} from 'react'; -import {StyleSheet,View,Text,Image,StatusBar,ScrollView,Alert} from 'react-native'; -let theme=require('./../../utils/theme.json'); -import {readUser,updatePosition,updateUserData} from './../../webservice/AuthApi'; -import {getAgentNetworksList} from './../../webservice/NetworkApi' -import {responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions'; -import MapView,{Marker} from 'react-native-maps'; +import React, {Component} from 'react'; +import {Alert, View} from 'react-native'; +import {readUser, updatePosition, updateUserData} from './../../webservice/AuthApi'; +import {responsiveHeight} from 'react-native-responsive-dimensions'; import Icon from 'react-native-vector-icons/FontAwesome5' import Button from 'apsl-react-native-button' -import CardView from "react-native-cardview"; -const route=require('./../../route.json') import I18n from 'react-native-i18n' -import {Header} from "react-native-elements"; import {IlinkEmitter} from "../../utils/events"; +import Geolocation from 'react-native-geolocation-service'; + +let theme = require('./../../utils/theme.json'); + +const route = require('./../../route.json') + require('./../../utils/Translations') -const height=responsiveHeight(100)-250; -export default class UpdateInformations extends Component { +const height = responsiveHeight(100) - 250; +export default class UpdateInformations extends Component { static navigatorStyle = { navBarHidden: false, navBarBackgroundColor: theme.primaryDark, @@ -25,101 +25,114 @@ export default class UpdateInformations extends Component { statusBarColor: theme.primaryDarkAdvanced, statusBarTextColorScheme: 'light', }; - static options(passProps){ + + static options(passProps) { return { - statusBar:{ - drawBehind:false + statusBar: { + drawBehind: false }, - topBar:{ - title:{ - text:"Mise à jour des informations", - color:"white" + topBar: { + title: { + text: "Mise à jour des informations", + color: "white" }, - background:{ - color:theme.primaryDark + background: { + color: theme.primaryDark } } } } - static navigationOptions = ({navigation})=>{ + + static navigationOptions = ({navigation}) => { return { - headerTitle: I18n.t('CHANGE_INFORMATION'), - drawerIcon: ({ tintColor }) => ( - - ), - }}; - constructor(props){ + headerTitle: I18n.t('CHANGE_INFORMATION'), + drawerIcon: ({tintColor}) => ( + + ), + } + }; + + constructor(props) { super(props) - this.state=this.initiateItems() + this.state = this.initiateItems() IlinkEmitter.on("langueChange", this.updateLangue.bind(this)) this.showUserState() } - async showUserState(){ - const user=await readUser() - this.setState({user:user}) - if(user.longitude<=0 && user.latitude<=0){ - Alert.alert(I18n.t('TITLE_NEED_POSITION'),I18n.t('TEXT_NEED_POSITION'),[{text:'Ok'}]) + + async showUserState() { + const user = await readUser() + this.setState({user: user}) + if (user.longitude <= 0 && user.latitude <= 0) { + Alert.alert(I18n.t('TITLE_NEED_POSITION'), I18n.t('TEXT_NEED_POSITION'), [{text: 'Ok'}]) } } - updateLangue(){ - this.props.navigation.setParams({name:I18n.t('CHANGE_INFORMATION')}) + updateLangue() { + this.props.navigation.setParams({name: I18n.t('CHANGE_INFORMATION')}) this.forceUpdate() } - render(){ + + render() { return ( - + - ); + isLoading={this.state.positionEnabled} + style={{ + backgroundColor: theme.primaryDark, + marginTop: responsiveHeight(5), + height: responsiveHeight(7), + marginRight: 10, + marginLeft: 10, + borderColor: 'transparent' + }} textStyle={{color: "white", fontSize: 20, fontWeight: 'bold'}} + onPress={() => this.onClickUpdatePosition()}>{I18n.t('UPDATE_POSITION_TEXT')} + ); } initiateItems() { - return{ - positionEnabled:false, + return { + positionEnabled: false, } } - onClickUpdatePosition() { - this.setState({positionEnabled:true}) - navigator.geolocation.getCurrentPosition((position) => { + onClickUpdatePosition() { + this.setState({positionEnabled: true}) + Geolocation.getCurrentPosition((position) => { const myPosition = position.coords; - updatePosition(myPosition.longitude,myPosition.latitude).then((response)=> { - var title=''; - var message=''; - this.setState({positionEnabled:false}) + updatePosition(myPosition.longitude, myPosition.latitude).then((response) => { + var title = ''; + var message = ''; + this.setState({positionEnabled: false}) console.log(response.error) - if(response.error===undefined){ - updateUserData({longitude:myPosition.longitude,latitude:myPosition.latitude}) - message=I18n.t('POSITION_UPDATE_SUCCESS_TEXT') - title=I18n.t('UPDATE_SUCCESS'); - }else{ - title=I18n.t("TITLE_UPDATE_POSITION_FAILED") - switch (response.error){ - case -3:message=I18n.t('TEXT_UDATE_POSITION_FAILED_1');break - case -2:message=I18n.t('TEXT_UDATE_POSITION_FAILED_2'); - break; + if (response.error === undefined) { + updateUserData({longitude: myPosition.longitude, latitude: myPosition.latitude}) + message = I18n.t('POSITION_UPDATE_SUCCESS_TEXT') + title = I18n.t('UPDATE_SUCCESS'); + } else { + title = I18n.t("TITLE_UPDATE_POSITION_FAILED") + switch (response.error) { + case -3: + message = I18n.t('TEXT_UDATE_POSITION_FAILED_1'); + break + case -2: + message = I18n.t('TEXT_UDATE_POSITION_FAILED_2'); + break; } } - Alert.alert(title,message,[{text:"Ok",onPress:()=>{ - this.props.navigation.popToTop() - }}]) - }).catch((e)=>{ - this.setState({positionEnabled:false}) + Alert.alert(title, message, [{ + text: "Ok", onPress: () => { + this.props.navigation.popToTop() + } + }]) + }).catch((e) => { + this.setState({positionEnabled: false}) }) }, null, this.props.geolocationOptions); diff --git a/screens/history-request/MyHistory.js b/screens/history-request/MyHistory.js index 5d48367d..9c1b453a 100644 --- a/screens/history-request/MyHistory.js +++ b/screens/history-request/MyHistory.js @@ -21,7 +21,6 @@ import {accent, primary, primaryDark, purpleLight} from './../../utils/theme.jso import {PagerTabIndicator} from 'react-native-best-viewpager' import IconWithBadge from "../IconWithBadge"; import {Appbar, Divider, Menu, Provider} from 'react-native-paper'; -import DeviceInfo from 'react-native-device-info'; var moment = require('moment-timezone'); const momentJS = require('moment'); @@ -322,11 +321,11 @@ class MyHistory extends React.Component { } > - { + {/* { this.setState({isSectionned: !this.state.isSectionned}) this._closeMenu() }} - title="Section"/> + title="Section"/>*/} { diff --git a/screens/identification/ModifyIdentificationUser.js b/screens/identification/ModifyIdentificationUser.js index c7823558..6fe5fd8b 100644 --- a/screens/identification/ModifyIdentificationUser.js +++ b/screens/identification/ModifyIdentificationUser.js @@ -2,644 +2,697 @@ import DateTimePicker from '@react-native-community/datetimepicker'; import Button from 'apsl-react-native-button'; import isEqual from 'lodash/isEqual'; import isNil from 'lodash/isNil'; -import React, { Component } from 'react'; -import { Alert, Keyboard, PermissionsAndroid, Platform, ProgressBarAndroid, ScrollView, StyleSheet, Text, View } from 'react-native'; +import React, {Component} from 'react'; +import { + Alert, + Keyboard, + PermissionsAndroid, + Platform, + ProgressBarAndroid, + ScrollView, + StyleSheet, + Text, + View +} from 'react-native'; import * as Animatable from 'react-native-animatable'; import Geolocation from 'react-native-geolocation-service'; import I18n from 'react-native-i18n'; -import { MaterialDialog } from "react-native-material-dialog"; -import { Dropdown } from 'react-native-material-dropdown'; -import { responsiveHeight, responsiveWidth } from 'react-native-responsive-dimensions'; -import { ProgressDialog } from 'react-native-simple-dialogs'; -import { Fumi } from 'react-native-textinput-effects'; +import {MaterialDialog} from "react-native-material-dialog"; +import {Dropdown} from 'react-native-material-dropdown'; +import {responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions'; +import {ProgressDialog} from 'react-native-simple-dialogs'; +import {Fumi} from 'react-native-textinput-effects'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; -import { Color } from '../../config/Color'; -import { store } from '../../redux/store'; -import { identityPieces } from '../../utils/UtilsFunction'; -import { createIndentificationResetAction, getNumberDetailAction, getNumberResetAction, getUserIdentificationAction, updateIndentificationAction } from '../../webservice/IdentificationApi'; -import { getListCountriesActive, getTownInformationName, readUser } from './../../webservice/AuthApi'; -import { getPositionInformation } from './../../webservice/MapService'; +import {connect} from 'react-redux'; +import {bindActionCreators} from 'redux'; +import {Color} from '../../config/Color'; +import {store} from '../../redux/store'; +import {identityPieces} from '../../utils/UtilsFunction'; +import { + createIndentificationResetAction, + getNumberDetailAction, + getNumberResetAction, + getUserIdentificationAction, + updateIndentificationAction +} from '../../webservice/IdentificationApi'; +import {getListCountriesActive, getTownInformationName, readUser} from './../../webservice/AuthApi'; +import {getPositionInformation} from './../../webservice/MapService'; + let theme = require('./../../utils/theme.json'); let route = require('./../../route.json'); -const GEOLOCATION_OPTIONS = { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000, useSignificantChanges: true }; +const GEOLOCATION_OPTIONS = {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000, useSignificantChanges: true}; const moment = require('moment'); class ModifyIdentificationUser extends Component { - static navigatorStyle = { - navBarBackgroundColor: Color.primaryColor, - statusBarColor: Color.primaryDarkColor, - navBarTextColor: '#FFFFFF', - navBarButtonColor: '#FFFFFF' + static navigatorStyle = { + navBarBackgroundColor: Color.primaryColor, + statusBarColor: Color.primaryDarkColor, + navBarTextColor: '#FFFFFF', + navBarButtonColor: '#FFFFFF' - }; + }; - static navigationOptions = () => { - return { - drawerLabel: () => null, - headerTitle: I18n.t('IDENTIFICATION'), - headerTintColor: 'white', - headerStyle: { - backgroundColor: Color.primaryColor, - marginTop: 0, - color: 'white' - }, - headerTitleStyle: { - color: "white" - }, - title: I18n.t('IDENTIFICATION') - } - }; + static navigationOptions = () => { + return { + drawerLabel: () => null, + headerTitle: I18n.t('IDENTIFICATION'), + headerTintColor: 'white', + headerStyle: { + backgroundColor: Color.primaryColor, + marginTop: 0, + color: 'white' + }, + headerTitleStyle: { + color: "white" + }, + title: I18n.t('IDENTIFICATION') + } + }; - constructor(props) { - super(props); - this.state = { - enterPhone: null, - firstname: null, - lastname: null, - numeroIdentite: null, - dateNaissance: null, - dateExpiration: null, - numeroTelephone: null, - networksinglePickerVisible: false, - confirmpassanim: null, - isLoging: false, - countries: [], - town: [], - townName: null, - country: null, - identityPieces: identityPieces(), - identityPiecesName: I18n.t((identityPieces()[0]).name), - snackVisible: false, - snackText: '', - disableNetwork: false, - networks: [], - showPickerDateNaissance: false, - showPickerDateExpiration: false, - modalVisible: true, - user: null, - triggerSubmitClick: false, - triggerNextClick: false, - displayFirstStep: true, - displaySecondStep: false, - userIdentificationData: store.getState().getUserIdentificationReducer.result.response.data - }; - this.dateNaissanceFumiProps = {}; - this.dateExpirationFumiProps = {}; - this.props.createIndentificationResetAction(); + constructor(props) { + super(props); + this.state = { + enterPhone: null, + firstname: null, + lastname: null, + numeroIdentite: null, + dateNaissance: null, + dateExpiration: null, + numeroTelephone: null, + networksinglePickerVisible: false, + confirmpassanim: null, + isLoging: false, + countries: [], + town: [], + townName: null, + country: null, + identityPieces: identityPieces(), + identityPiecesName: I18n.t((identityPieces()[0]).name), + snackVisible: false, + snackText: '', + disableNetwork: false, + networks: [], + showPickerDateNaissance: false, + showPickerDateExpiration: false, + modalVisible: true, + user: null, + triggerSubmitClick: false, + triggerNextClick: false, + displayFirstStep: true, + displaySecondStep: false, + userIdentificationData: store.getState().getUserIdentificationReducer.result.response.data + }; + this.dateNaissanceFumiProps = {}; + this.dateExpirationFumiProps = {}; + this.props.createIndentificationResetAction(); - } + } - componentDidMount() { + componentDidMount() { - this.dateNaissanceFumiProps.value = moment(this.state.userIdentificationData.birth_date).format('DD-MM-YYYY'); - this.dateExpirationFumiProps.value = moment(this.state.userIdentificationData.expiry_date_document).format('DD-MM-YYYY'); + this.dateNaissanceFumiProps.value = this.state.userIdentificationData !== null ? moment(this.state.userIdentificationData.birth_date).format('DD-MM-YYYY') : ""; + this.dateExpirationFumiProps.value = this.state.userIdentificationData !== null ? moment(this.state.userIdentificationData.expiry_date_document).format('DD-MM-YYYY') : ""; - readUser().then((user) => { - if (user) { - if (user !== undefined) { - //this.props.getNumberDetailAction(user.phone); - this.setState({ - user, - lastname: this.state.userIdentificationData.firstname + ' ' + this.state.userIdentificationData.lastname, - numeroIdentite: this.state.userIdentificationData.id_identity_document - }); - } - } - }); + readUser().then((user) => { + if (user) { + if (user !== undefined) { + //this.props.getNumberDetailAction(user.phone); + this.setState({ + user, + lastname: this.state.userIdentificationData.firstname + ' ' + this.state.userIdentificationData.lastname, + numeroIdentite: this.state.userIdentificationData.id_identity_document + }); + } + } + }); - if (Platform.OS === 'android') { - this.requestCameraPermission(); - } else { - this.watchLocation(); - } + if (Platform.OS === 'android') { + this.requestCameraPermission(); + } else { + this.watchLocation(); + } - } + } - renderCreateIdentificationResponse() { - const { result, error } = this.props; + renderCreateIdentificationResponse() { + const {result, error} = this.props; - console.log("PROPS", this.props); + console.log("PROPS", this.props); - if (result !== null) { - if (typeof result.response !== 'undefined') { - Alert.alert( - I18n.t('SUCCESS_IDENTIFICATION'), - result.response, - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.getUserIdentificationAction(this.state.user.phone); - this.props.createIndentificationResetAction(); - this.setState({ triggerSubmitClick: false }); - this.props.navigation.pop(); - } - } + if (result !== null) { + if (typeof result.response !== 'undefined') { + Alert.alert( + I18n.t('SUCCESS_IDENTIFICATION'), + result.response, + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.getUserIdentificationAction(this.state.user.phone); + this.props.createIndentificationResetAction(); + this.setState({triggerSubmitClick: false}); + this.props.navigation.pop(); + } + } - ], - { cancelable: false } - ) - } - } + ], + {cancelable: false} + ) + } + } - if (error !== null) { - if (typeof error.data !== 'undefined') { - Alert.alert( - I18n.t('ERROR_IDENTIFICATION'), - error.data.error, - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.createIndentificationResetAction(); - this.setState({ triggerSubmitClick: false }); - } - } + if (error !== null) { + if (typeof error.data !== 'undefined') { + Alert.alert( + I18n.t('ERROR_IDENTIFICATION'), + error.data.error, + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.createIndentificationResetAction(); + this.setState({triggerSubmitClick: false}); + } + } - ], - { cancelable: false } - ) - } else { - Alert.alert( - I18n.t('ERROR_IDENTIFICATION'), - JSON.stringify(error), - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.createIndentificationResetAction(); - } - } + ], + {cancelable: false} + ) + } else { + Alert.alert( + I18n.t('ERROR_IDENTIFICATION'), + JSON.stringify(error), + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.createIndentificationResetAction(); + } + } - ], - { cancelable: false } - ) - } - } - } + ], + {cancelable: false} + ) + } + } + } - componentWillUpdate(nextProps, nextState) { - let dateNaissance = nextState.dateNaissance || new Date(); + componentWillUpdate(nextProps, nextState) { + let dateNaissance = nextState.dateNaissance || new Date(); - if (this.state.showPickerDateNaissance) - this.dateNaissanceFumiProps.value = moment(dateNaissance).format('DD-MM-YYYY'); - if (this.state.showPickerDateExpiration) - this.dateExpirationFumiProps.value = moment(nextState.dateExpiration).format('DD-MM-YYYY'); - } + if (this.state.showPickerDateNaissance) + this.dateNaissanceFumiProps.value = moment(dateNaissance).format('DD-MM-YYYY'); + if (this.state.showPickerDateExpiration) + this.dateExpirationFumiProps.value = moment(nextState.dateExpiration).format('DD-MM-YYYY'); + } - componentWillUnmount() { - this.mounted = false; - if (this.watchID) Geolocation.clearWatch(this.watchID); - } + componentWillUnmount() { + this.mounted = false; + if (this.watchID) Geolocation.clearWatch(this.watchID); + } - showErrorDialog() { - this.setState({ modalDialog: false }) - Alert.alert("Une erreur est survenue", "Impossible de récuperer des informations du pays verifier que votre gps est activé," + - "et que vous êtes connecté à internet puis ressayer", [{ - text: "Recommencer", onPress: () => { - this.watchLocation() - } - }, { text: "Annuler", onPress: () => { this.props.navigation.popToTop() } }]) - } + showErrorDialog() { + this.setState({modalDialog: false}) + Alert.alert("Une erreur est survenue", "Impossible de récuperer des informations du pays verifier que votre gps est activé," + + "et que vous êtes connecté à internet puis ressayer", [{ + text: "Recommencer", onPress: () => { + this.watchLocation() + } + }, { + text: "Annuler", onPress: () => { + this.props.navigation.popToTop() + } + }]) + } - async watchLocation() { - Geolocation.getCurrentPosition((position) => { - this.treatPosition(position) - }, (e) => { - this.showErrorDialog() - }, this.props.geolocationOptions); - if (!this.watchID) { - Geolocation.watchPosition((position) => { this.treatPosition(position) }, (e) => { this.showErrorDialog() }, this.props.geolocationOptions) - } - } + async watchLocation() { + Geolocation.getCurrentPosition((position) => { + this.treatPosition(position) + }, (e) => { + this.showErrorDialog() + }, this.props.geolocationOptions); + if (!this.watchID) { + Geolocation.watchPosition((position) => { + this.treatPosition(position) + }, (e) => { + this.showErrorDialog() + }, this.props.geolocationOptions) + } + } - async requestCameraPermission() { - try { - const granted = await PermissionsAndroid.request( - PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, - { - 'title': 'Cool Photo App Camera Permission', - 'message': 'Cool Photo App needs access to your camera ' + - 'so you can take awesome pictures.' - } - ) - if (granted === PermissionsAndroid.RESULTS.GRANTED) { - this.watchLocation(); - } else { - this.setState({ modalDialog: false }) - Alert.alert("Echec à l'autorisation", - "L'application n'est pas autorisé à acceder à votre position veuillez verifier que votre GPS est activé et configurer en mode Haute Precision", - [{ - text: "Ok", onPress: () => { - this.props.navigation.popToTop() - } - }]) - } - } catch (err) { - this.setState({ modalDialog: false }) - Alert.alert("Une erreur est Survenue", - "Une erreur est survenu lors du demarrage de l'application veuillez relancer l'application", + async requestCameraPermission() { + try { + const granted = await PermissionsAndroid.request( + PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, + { + 'title': 'Cool Photo App Camera Permission', + 'message': 'Cool Photo App needs access to your camera ' + + 'so you can take awesome pictures.' + } + ) + if (granted === PermissionsAndroid.RESULTS.GRANTED) { + this.watchLocation(); + } else { + this.setState({modalDialog: false}) + Alert.alert("Echec à l'autorisation", + "L'application n'est pas autorisé à acceder à votre position veuillez verifier que votre GPS est activé et configurer en mode Haute Precision", [{ - text: "Ok", onPress: () => { - BackHandler.exitApp() - } + text: "Ok", onPress: () => { + this.props.navigation.popToTop() + } }]) - } - } + } + } catch (err) { + this.setState({modalDialog: false}) + Alert.alert("Une erreur est Survenue", + "Une erreur est survenu lors du demarrage de l'application veuillez relancer l'application", + [{ + text: "Ok", onPress: () => { + BackHandler.exitApp() + } + }]) + } + } - treatPosition(position) { - const myLastPosition = this.state.myPosition; - const myPosition = position.coords; + treatPosition(position) { + const myLastPosition = this.state.myPosition; + const myPosition = position.coords; - if (!isEqual(myPosition, myLastPosition)) { - getPositionInformation(myPosition).then((response) => { - if (response.results !== undefined) { - if (response.results.length > 0) { - let most = response.results[0] - let { address_components, formatted_address, place_id } = most - this.setState({ address: address_components, textadress: formatted_address, place: place_id }) + if (!isEqual(myPosition, myLastPosition)) { + getPositionInformation(myPosition).then((response) => { + if (response.results !== undefined) { + if (response.results.length > 0) { + let most = response.results[0] + let {address_components, formatted_address, place_id} = most + this.setState({address: address_components, textadress: formatted_address, place: place_id}) - let results = response.results; - let shortcountry; - let mcountry; - for (let i = 0; i < results[0].address_components.length; i++) { - for (let j = 0; j < results[0].address_components[i].types.length; j++) { - if (results[0].address_components[i].types[j] === "country") { - mcountry = results[0].address_components[i]; - shortcountry = mcountry.short_name; - this.setState({ shortCountry: mcountry.short_name, longCountry: mcountry.long_name }) - } else if (results[0].address_components[i].types[j] === "locality") { - const name = results[0].address_components[i].short_name; - this.setState({ townName: name }); - getTownInformationName(name).then((result) => { - let town = null; - if (result instanceof Array) { - town = result[0]; - } else { - town = result; - } - - this.setState({ modalVisible: false, town: new Array(town) }); - }) + let results = response.results; + let shortcountry; + let mcountry; + for (let i = 0; i < results[0].address_components.length; i++) { + for (let j = 0; j < results[0].address_components[i].types.length; j++) { + if (results[0].address_components[i].types[j] === "country") { + mcountry = results[0].address_components[i]; + shortcountry = mcountry.short_name; + this.setState({shortCountry: mcountry.short_name, longCountry: mcountry.long_name}) + } else if (results[0].address_components[i].types[j] === "locality") { + const name = results[0].address_components[i].short_name; + this.setState({townName: name}); + getTownInformationName(name).then((result) => { + let town = null; + if (result instanceof Array) { + town = result[0]; + } else { + town = result; } - } - } - getListCountriesActive().then((cnt) => { - this.setState({ countries: cnt }) - console.debug(cnt, shortcountry); - var found = false - for (let i of cnt) { - if (i.code_country === shortcountry) { - found = true; - this.setState({ modalVisible: false, indicatif: i.code_dial, country: i.name }) - /* this.getNetworks(i.code_dial); */ - } - } - if (!found) { - Alert.alert("Impossible de recupérer vos informations", "Nous n'avons pas pu recuperer les informations de votre pays veuillez contacter les administrateurs", [{ text: "OK" }]); - } - }) + this.setState({modalVisible: false, town: new Array(town)}); + }) + } + } + } + getListCountriesActive().then((cnt) => { + this.setState({countries: cnt}) + console.debug(cnt, shortcountry); + var found = false + for (let i of cnt) { + if (i.code_country === shortcountry) { + found = true; + this.setState({modalVisible: false, indicatif: i.code_dial, country: i.name}) + /* this.getNetworks(i.code_dial); */ + } + } + if (!found) { + Alert.alert("Impossible de recupérer vos informations", "Nous n'avons pas pu recuperer les informations de votre pays veuillez contacter les administrateurs", [{text: "OK"}]); + } + }) - } } - }).catch((e) => { - this.showErrorDialog() - }); - this.setState({ myPosition: myPosition }); - } - } + } + }).catch((e) => { + this.showErrorDialog() + }); + this.setState({myPosition: myPosition}); + } - onChangeDateNaissance = (event, selectedDate) => { - let dateNaissance = isNil(this.state.dateNaissance) ? new Date() : this.state.dateNaissance; - const currentDate = selectedDate || dateNaissance; - this.setState({ - showPickerDateNaissance: Platform.OS === 'ios' || false, - dateNaissance: currentDate, - }); - }; + } - onChangeDateExpiration = (event, selectedDate) => { - let dateExpiration = isNil(this.state.dateExpiration) ? new Date() : this.state.dateExpiration; - const currentDate = selectedDate || dateExpiration; - this.setState({ - showPickerDateExpiration: Platform.OS === 'ios' || false, - dateExpiration: currentDate, - }); - }; + onChangeDateNaissance = (event, selectedDate) => { + let dateNaissance = isNil(this.state.dateNaissance) ? new Date() : this.state.dateNaissance; + const currentDate = selectedDate || dateNaissance; + this.setState({ + showPickerDateNaissance: Platform.OS === 'ios' || false, + dateNaissance: currentDate, + }); + }; - ckeckIfFieldIsOK(champ) { - return (isNil(champ) || isEqual(champ.length, 0)); - } + onChangeDateExpiration = (event, selectedDate) => { + let dateExpiration = isNil(this.state.dateExpiration) ? new Date() : this.state.dateExpiration; + const currentDate = selectedDate || dateExpiration; + this.setState({ + showPickerDateExpiration: Platform.OS === 'ios' || false, + dateExpiration: currentDate, + }); + }; - onSubmitIdentityClient = () => { - const { lastname, numeroIdentite, dateNaissance, dateExpiration, country, townName, identityPiecesName } = this.state; + ckeckIfFieldIsOK(champ) { + return (isNil(champ) || isEqual(champ.length, 0)); + } - if (this.ckeckIfFieldIsOK(lastname)) - this.lastnameAnim.shake(800); - /* else if (this.ckeckIfFieldIsOK(dateNaissance)) - this.datenaissanceAnim.shake(800); - else if (this.ckeckIfFieldIsOK(dateExpiration)) - this.identityDateExpiryAnim.shake(800); */ - else if (this.ckeckIfFieldIsOK(country)) - this.countryAnim.shake(800); - else if (this.ckeckIfFieldIsOK(townName)) - this.townAnim.shake(800); - else if (this.ckeckIfFieldIsOK(identityPiecesName)) - this.identityPiecesAnim.shake(800); - else if (this.ckeckIfFieldIsOK(numeroIdentite)) - this.numeroIdentiteAnim.shake(800); - else { - console.log('USER ID', this.state.user.id); - moment(dateNaissance).format('DD-MM-YYYY') - this.props.updateIndentificationAction({ - id: this.state.userIdentificationData.id, - lastname: this.state.lastname, - firstname: "", - birth_date: isNil(this.state.dateNaissance) ? this.dateNaissanceFumiProps.value : moment(this.state.dateNaissance).format('DD-MM-YYYY'), - town: this.state.townName, - country: this.state.country, - identity_document: this.state.identityPiecesName, - id_identity_document: this.state.numeroIdentite, - expiry_date_document: isNil(this.state.dateExpiration) ? this.dateExpirationFumiProps.value : moment(this.state.dateExpiration).format('DD-MM-YYYY'), - }); - } - this.setState({ - triggerSubmitClick: true - }) + onSubmitIdentityClient = () => { + const {lastname, numeroIdentite, dateNaissance, dateExpiration, country, townName, identityPiecesName} = this.state; - } + if (this.ckeckIfFieldIsOK(lastname)) + this.lastnameAnim.shake(800); + /* else if (this.ckeckIfFieldIsOK(dateNaissance)) + this.datenaissanceAnim.shake(800); + else if (this.ckeckIfFieldIsOK(dateExpiration)) + this.identityDateExpiryAnim.shake(800); */ + else if (this.ckeckIfFieldIsOK(country)) + this.countryAnim.shake(800); + else if (this.ckeckIfFieldIsOK(townName)) + this.townAnim.shake(800); + else if (this.ckeckIfFieldIsOK(identityPiecesName)) + this.identityPiecesAnim.shake(800); + else if (this.ckeckIfFieldIsOK(numeroIdentite)) + this.numeroIdentiteAnim.shake(800); + else { + console.log('USER ID', this.state.user.id); + moment(dateNaissance).format('DD-MM-YYYY') + this.props.updateIndentificationAction({ + id: this.state.userIdentificationData.id, + lastname: this.state.lastname, + firstname: "", + birth_date: isNil(this.state.dateNaissance) ? this.dateNaissanceFumiProps.value : moment(this.state.dateNaissance).format('DD-MM-YYYY'), + town: this.state.townName, + country: this.state.country, + identity_document: this.state.identityPiecesName, + id_identity_document: this.state.numeroIdentite, + expiry_date_document: isNil(this.state.dateExpiration) ? this.dateExpirationFumiProps.value : moment(this.state.dateExpiration).format('DD-MM-YYYY'), + }); + } + this.setState({ + triggerSubmitClick: true + }) - renderLoaderModal() { - return ( - - - {I18n.t("LOADING_DESCRIPTION_COUNTRY")} - - - ) - } + } - renderLoader = () => { - return ( - - ) - } + renderLoaderModal() { + return ( + + + {I18n.t("LOADING_DESCRIPTION_COUNTRY")} + + + ) + } - renderDateNaissancePicker = () => { - return ( - - ); - } + renderLoader = () => { + return ( + + ) + } - renderDateExpirationPicker = () => { - return ( - - ); - } + renderDateNaissancePicker = () => { + return ( + + ); + } - render() { - console.log("STATE", this.state); - const { showPickerDateNaissance } = this.state; - return ( - <> - {this.state.showPickerDateNaissance && this.renderDateNaissancePicker()} - {this.state.showPickerDateExpiration && this.renderDateExpirationPicker()} - {this.state.modalVisible && this.renderLoaderModal()} - {(this.props.loading || this.props.loadingNumberDetail) && this.renderLoader()} - {this.state.triggerSubmitClick && this.renderCreateIdentificationResponse()} - + renderDateExpirationPicker = () => { + return ( + + ); + } - { this.lastnameAnim = comp }}> - { - this.setState({ lastname }) - }} - style={styles.input} - > - - + render() { + console.log("STATE", this.state); + const {showPickerDateNaissance} = this.state; + return ( + <> + {this.state.showPickerDateNaissance && this.renderDateNaissancePicker()} + {this.state.showPickerDateExpiration && this.renderDateExpirationPicker()} + {this.state.modalVisible && this.renderLoaderModal()} + {(this.props.loading || this.props.loadingNumberDetail) && this.renderLoader()} + {this.state.triggerSubmitClick && this.renderCreateIdentificationResponse()} + - { this.datenaissanceAnim = comp }}> - { - Keyboard.dismiss(); - this.setState({ showPickerDateNaissance: true }) - }} - {...this.dateNaissanceFumiProps}> - - + { + this.lastnameAnim = comp + }}> + { + this.setState({lastname}) + }} + style={styles.input} + > + + - { this.countryAnim = comp }} - style={{ - width: responsiveWidth(90), - height: 60, - marginTop: 20, - alignSelf: 'center', - borderRadius: 10, - paddingLeft: 20, - paddingRight: 20, - backgroundColor: 'white' - }}> - { - this.setState({ country: value }); - }} - valueExtractor={(value) => { return value.name }} - labelExtractor={(value) => { return value.name }} - /> - + { + this.datenaissanceAnim = comp + }}> + { + Keyboard.dismiss(); + this.setState({showPickerDateNaissance: true}) + }} + {...this.dateNaissanceFumiProps}> + + - { this.townAnim = comp }} - style={{ - width: responsiveWidth(90), - height: 60, - marginTop: 20, - alignSelf: 'center', - borderRadius: 10, - paddingLeft: 20, - paddingRight: 20, - backgroundColor: 'white' - }}> - { - this.setState({ townName: value }); - }} - valueExtractor={(value) => { return value.name }} - labelExtractor={(value) => { return value.name }} - /> - + { + this.countryAnim = comp + }} + style={{ + width: responsiveWidth(90), + height: 60, + marginTop: 20, + alignSelf: 'center', + borderRadius: 10, + paddingLeft: 20, + paddingRight: 20, + backgroundColor: 'white' + }}> + { + this.setState({country: value}); + }} + valueExtractor={(value) => { + return value.name + }} + labelExtractor={(value) => { + return value.name + }} + /> + - { this.identityPiecesAnim = comp }} - style={{ - width: responsiveWidth(90), - height: 60, - marginTop: 20, - alignSelf: 'center', - borderRadius: 10, - paddingLeft: 20, - paddingRight: 20, - backgroundColor: 'white' - }}> - { - this.setState({ identityPiecesName: value }); - }} - valueExtractor={(value) => { return I18n.t(value.name) }} - labelExtractor={(value) => { return I18n.t(value.name) }} - /> - - { this.numeroIdentiteAnim = comp }}> - { - this.setState({ numeroIdentite }) - }} - style={styles.input} - > - - - { this.identityDateExpiryAnim = comp }}> - { - Keyboard.dismiss(); - this.setState({ showPickerDateExpiration: true }) - }} - {...this.dateExpirationFumiProps}> - - + { + this.townAnim = comp + }} + style={{ + width: responsiveWidth(90), + height: 60, + marginTop: 20, + alignSelf: 'center', + borderRadius: 10, + paddingLeft: 20, + paddingRight: 20, + backgroundColor: 'white' + }}> + { + this.setState({townName: value}); + }} + valueExtractor={(value) => { + return value.name + }} + labelExtractor={(value) => { + return value.name + }} + /> + - - - - ) - } + { + this.identityPiecesAnim = comp + }} + style={{ + width: responsiveWidth(90), + height: 60, + marginTop: 20, + alignSelf: 'center', + borderRadius: 10, + paddingLeft: 20, + paddingRight: 20, + backgroundColor: 'white' + }}> + { + this.setState({identityPiecesName: value}); + }} + valueExtractor={(value) => { + return I18n.t(value.name) + }} + labelExtractor={(value) => { + return I18n.t(value.name) + }} + /> + + { + this.numeroIdentiteAnim = comp + }}> + { + this.setState({numeroIdentite}) + }} + style={styles.input} + > + + + { + this.identityDateExpiryAnim = comp + }}> + { + Keyboard.dismiss(); + this.setState({showPickerDateExpiration: true}) + }} + {...this.dateExpirationFumiProps}> + + + + + + + ) + } } const maptStateToProps = state => ({ - loading: state.createIdentificationReducer.loading, - result: state.createIdentificationReducer.result, - error: state.createIdentificationReducer.error, + loading: state.createIdentificationReducer.loading, + result: state.createIdentificationReducer.result, + error: state.createIdentificationReducer.error, - loadingNumberDetail: state.getNumberInformationReducer.loading, - resultNumberDetail: state.getNumberInformationReducer.result, - errorNumberDetail: state.getNumberInformationReducer.error, + loadingNumberDetail: state.getNumberInformationReducer.loading, + resultNumberDetail: state.getNumberInformationReducer.result, + errorNumberDetail: state.getNumberInformationReducer.error, }); const mapDispatchToProps = dispatch => bindActionCreators({ - updateIndentificationAction, - createIndentificationResetAction, - getUserIdentificationAction, - getNumberDetailAction, - getNumberResetAction + updateIndentificationAction, + createIndentificationResetAction, + getUserIdentificationAction, + getNumberDetailAction, + getNumberResetAction }, dispatch); export default connect(maptStateToProps, mapDispatchToProps)(ModifyIdentificationUser); const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: Color.primaryDarkColor, - }, - 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: Color.accentLightColor, - height: 52 - }, - btnSubmit: { - marginTop: 20, - borderColor: 'transparent', - backgroundColor: Color.accentLightColor, - height: 52, - width: "30%", - marginLeft: 20, - marginRight: 20, - }, - input: { - height: 60, - marginTop: responsiveHeight(2), - marginLeft: responsiveWidth(5), - marginRight: responsiveWidth(5), - borderRadius: 5, - } + container: { + flex: 1, + backgroundColor: Color.primaryDarkColor, + }, + 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: Color.accentLightColor, + height: 52 + }, + btnSubmit: { + marginTop: 20, + borderColor: 'transparent', + backgroundColor: Color.accentLightColor, + height: 52, + width: "30%", + marginLeft: 20, + marginRight: 20, + }, + input: { + height: 60, + marginTop: responsiveHeight(2), + marginLeft: responsiveWidth(5), + marginRight: responsiveWidth(5), + borderRadius: 5, + } }); \ No newline at end of file diff --git a/screens/wallet/WalletOptionSelect.js b/screens/wallet/WalletOptionSelect.js index d2b8415c..1f4486ab 100644 --- a/screens/wallet/WalletOptionSelect.js +++ b/screens/wallet/WalletOptionSelect.js @@ -48,6 +48,7 @@ import {responsiveWidth} from 'react-native-responsive-dimensions'; import {getWalletDetailActivated} from "../../webservice/WalletApi"; import {getWalletTransactionHistoryUser} from "../../webservice/WalletTransactionHistoryApi"; import {getUserIdentificationAction} from "../../webservice/IdentificationApi"; +import {store} from "../../redux/store"; const route = require('./../../route.json'); let slugify = require('slugify'); @@ -64,7 +65,7 @@ class WalletOptionSelect extends Component { wallet: this.props.navigation.state.params.wallet, lottie: this.props.navigation.state.params.lottie, onGoBack: this.props.navigation.state.params.onGoBack, - isIdentified: this.props.navigation.state.params.isIdentified || null, + isIdentified: store.getState().getUserIdentificationReducer.result !== null ? store.getState().getUserIdentificationReducer.result.response.isIdentified : false, isNanoCredit: this.props.navigation.state.params.hasOwnProperty('isNanoCredit'), user: null, displayModalHistory: false, diff --git a/screens/wallet/agent/EnvoiCashVersCashAgent.js b/screens/wallet/agent/EnvoiCashVersCashAgent.js index 3a8278eb..704aa8d5 100644 --- a/screens/wallet/agent/EnvoiCashVersCashAgent.js +++ b/screens/wallet/agent/EnvoiCashVersCashAgent.js @@ -1,547 +1,676 @@ import Button from 'apsl-react-native-button'; import isEqual from 'lodash/isEqual'; import isNil from 'lodash/isNil'; -import React, { Component } from 'react'; -import { Alert, ScrollView, StyleSheet, Text, View } from 'react-native'; +import React, {Component} from 'react'; +import {Alert, ScrollView, StyleSheet, Text, View} from 'react-native'; import * as Animatable from 'react-native-animatable'; import I18n from 'react-native-i18n'; import Dialog from "react-native-dialog"; -import { Dropdown } from 'react-native-material-dropdown'; -import { responsiveHeight, responsiveWidth } from 'react-native-responsive-dimensions'; -import { ProgressDialog } from 'react-native-simple-dialogs'; -import { Fumi } from 'react-native-textinput-effects'; +import {Dropdown} from 'react-native-material-dropdown'; +import {responsiveHeight, responsiveWidth} from 'react-native-responsive-dimensions'; +import {ProgressDialog} from 'react-native-simple-dialogs'; +import {Fumi} from 'react-native-textinput-effects'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; -import { Color } from '../../../config/Color'; -import { store } from "../../../redux/store"; -import { identityPieces, isIlinkWorldWallet, isNormalInteger, typeIdIDestinataire, thousandsSeparators } from '../../../utils/UtilsFunction'; -import { readUser } from '../../../webservice/AuthApi'; -import { getActiveCountryAction, getActiveCountryByDialCodeAction, getActiveCountryByDialCodeReset, getActiveCountryReset, getPayCountryNetworkAction, getPayCountryNetworkReset } from '../../../webservice/CountryApi'; -import { envoieUserWalletToCashAction, envoieUserWalletToCashReset, getCommissionUserWalletToCashAction, getCommissionUserWalletToCashReset } from '../../../webservice/EnvoieUserApi'; -import { Typography, FontWeight } from '../../../config/typography'; +import {connect} from 'react-redux'; +import {bindActionCreators} from 'redux'; +import {Color} from '../../../config/Color'; +import {store} from "../../../redux/store"; +import {identityPieces, isNormalInteger} from '../../../utils/UtilsFunction'; +import {readUser} from '../../../webservice/AuthApi'; +import { + getActiveCountryAction, + getActiveCountryByDialCodeAction, + getActiveCountryByDialCodeReset, + getActiveCountryReset, + getPayCountryNetworkAction, + getPayCountryNetworkReset +} from '../../../webservice/CountryApi'; +import { + envoieUserWalletToCashAction, + envoieUserWalletToCashReset, + getCommissionUserWalletToCashAction, + getCommissionUserWalletToCashReset +} from '../../../webservice/EnvoieUserApi'; +import {FontWeight, Typography} from '../../../config/typography'; import thousands from 'thousands'; -import { IlinkEmitter } from '../../../utils/events'; +import {IlinkEmitter} from '../../../utils/events'; + let theme = require('../../../utils/theme.json'); let route = require('../../../route.json'); class EnvoiCashVersCashAgent extends Component { - static navigatorStyle = { - navBarBackgroundColor: Color.primaryColor, - statusBarColor: Color.primaryDarkColor, - navBarTextColor: '#FFFFFF', - navBarButtonColor: '#FFFFFF' + static navigatorStyle = { + navBarBackgroundColor: Color.primaryColor, + statusBarColor: Color.primaryDarkColor, + navBarTextColor: '#FFFFFF', + navBarButtonColor: '#FFFFFF' - }; + }; - static navigationOptions = () => { - return { - drawerLabel: () => null, - headerTitle: I18n.t('DEPOSIT_CASH_TO_CASH'), - headerTintColor: 'white', - headerStyle: { - backgroundColor: Color.primaryColor, - marginTop: 0, - color: 'white' - }, - headerTitleStyle: { - color: "white" - }, - title: I18n.t('DEPOSIT_CASH_TO_CASH') - } - }; + static navigationOptions = () => { + return { + drawerLabel: () => null, + headerTitle: I18n.t('DEPOSIT_CASH_TO_CASH'), + headerTintColor: 'white', + headerStyle: { + backgroundColor: Color.primaryColor, + marginTop: 0, + color: 'white' + }, + headerTitleStyle: { + color: "white" + }, + title: I18n.t('DEPOSIT_CASH_TO_CASH') + } + }; - constructor(props) { - super(props); - this.state = { - identityPiecesEmetteur: identityPieces(), - identityPiecesNameEmetteur: I18n.t((identityPieces()[0]).name), - paysDestination: [], - paysDestinationSelect: null, - walletActifs: [], - walletActifSelect: null, - nomsEmetteur: null, - prenomsEmetteur: null, - emailEmetteur: null, - numeroIdentiteEmetteur: null, - nomsDestinataire: null, - prenomsDestinataire: null, - idDestinataire: null, - numeroIdentiteDestinataire: null, - montant: null, - password: null, - loading: false, - user: null, - triggerSubmitClick: false, - triggerNextClick: false, - displayFirstStep: true, - displaySecondStep: false, - modalVisible: false, - hasLoadActiveCountryList: false, - hasLoadActivePayCountryNetworkList: false, - triggerSubmitClick: false, - isDataSubmit: false, - isModalConfirmVisible: false, - wallet: store.getState().walletDetailReducer.result.response - }; + constructor(props) { + super(props); + this.state = { + identityPiecesEmetteur: identityPieces(), + identityPiecesNameEmetteur: I18n.t((identityPieces()[0]).name), + paysDestination: [], + paysDestinationSelect: null, + walletActifs: [], + walletActifSelect: null, + nomsEmetteur: null, + prenomsEmetteur: null, + emailEmetteur: null, + numeroIdentiteEmetteur: null, + nomsDestinataire: null, + prenomsDestinataire: null, + idDestinataire: null, + numeroIdentiteDestinataire: null, + montant: null, + password: null, + loading: false, + user: null, + triggerNextClick: false, + displayFirstStep: true, + displaySecondStep: false, + modalVisible: false, + hasLoadActiveCountryList: false, + hasLoadActivePayCountryNetworkList: false, + triggerSubmitClick: false, + isDataSubmit: false, + isModalConfirmVisible: false, + wallet: store.getState().walletDetailReducer.result.response + }; - this.props.getActiveCountryReset(); - this.props.getActiveCountryByDialCodeReset(); - this.props.getPayCountryNetworkReset(); - this.props.envoieUserWalletToCashReset(); - this.props.getCommissionUserWalletToCashReset(); + this.props.getActiveCountryReset(); + this.props.getActiveCountryByDialCodeReset(); + this.props.getPayCountryNetworkReset(); + this.props.envoieUserWalletToCashReset(); + this.props.getCommissionUserWalletToCashReset(); - } + } - componentDidMount() { + componentDidMount() { - readUser().then((user) => { - if (user) { - if (user !== undefined) { - this.setState({ user }); - } - } - }); + readUser().then((user) => { + if (user) { + if (user !== undefined) { + this.setState({user}); + } + } + }); - } + } - componentWillReceiveProps(nextProps) { + componentWillReceiveProps(nextProps) { - if (nextProps.resultEnvoieWalletToCashGetCommission != null) { + if (nextProps.resultEnvoieWalletToCashGetCommission != null) { - if (typeof nextProps.resultEnvoieWalletToCashGetCommission.response !== 'undefined') { - - if (!nextProps.loadingEnvoieWalletToCashGetCommission) - this.setState({ - isModalConfirmVisible: true - }); - } - } - } - - renderGetActionCountryList = () => { - - const { resultActiveCountryList, errorActiveCountryList } = this.props; - if (resultActiveCountryList !== null) { - if (typeof resultActiveCountryList.response !== 'undefined') { + if (typeof nextProps.resultEnvoieWalletToCashGetCommission.response !== 'undefined') { + if (!nextProps.loadingEnvoieWalletToCashGetCommission) this.setState({ - hasLoadActiveCountryList: false, - paysDestination: resultActiveCountryList.response, - paysDestinationSelect: resultActiveCountryList.response[0].name, + isModalConfirmVisible: true }); - if (this.state.hasLoadActivePayCountryNetworkList) - this.props.getPayCountryNetworkAction({ id_wallet_agent: this.state.wallet.id, id_country: resultActiveCountryList.response[0].id }); - } - } + } + } + } - if (errorActiveCountryList !== null) { - if (typeof errorActiveCountryList.data !== 'undefined') { - Alert.alert( - I18n.t('ERROR_LABEL'), - errorActiveCountryList.data.error, - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.getActiveCountryReset(); - } - } + renderGetActionCountryList = () => { - ], - { cancelable: false } - ) - } else { - Alert.alert( - I18n.t('ERROR_LABEL'), - JSON.stringify(errorActiveCountryList), - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.getActiveCountryReset(); - } - } + const {resultActiveCountryList, errorActiveCountryList} = this.props; + if (resultActiveCountryList !== null) { + if (typeof resultActiveCountryList.response !== 'undefined') { - ], - { cancelable: false } - ) - } - } - } + this.setState({ + hasLoadActiveCountryList: false, + paysDestination: resultActiveCountryList.response, + paysDestinationSelect: resultActiveCountryList.response[0].name, + }); + if (this.state.hasLoadActivePayCountryNetworkList) + this.props.getPayCountryNetworkAction({ + id_wallet_agent: this.state.wallet.id, + id_country: resultActiveCountryList.response[0].id + }); + } + } - renderGetPayCountryNetworkResponse = () => { - const { resultPayCountryNetwork, errorPayCountryNetwork } = this.props; - if (resultPayCountryNetwork !== null) { - if (typeof resultPayCountryNetwork.response !== 'undefined') { - if (resultPayCountryNetwork.response.length > 0) { - this.setState({ - hasLoadActivePayCountryNetworkList: false, - walletActifs: resultPayCountryNetwork.response, - walletActifSelect: resultPayCountryNetwork.response[0].name, - modalVisible: false - }); - } - else if (resultPayCountryNetwork.response.length === 0) { - this.setState({ - walletActifs: [], - walletActifSelect: '', - modalVisible: false, - hasLoadActivePayCountryNetworkList: false, - }); - } - } - } + if (errorActiveCountryList !== null) { + if (typeof errorActiveCountryList.data !== 'undefined') { + Alert.alert( + I18n.t('ERROR_LABEL'), + errorActiveCountryList.data.error, + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.getActiveCountryReset(); + } + } - if (errorPayCountryNetwork !== null) { - if (typeof errorPayCountryNetwork.data !== 'undefined') { - Alert.alert( - I18n.t('ERROR_LABEL'), - errorPayCountryNetwork.data.error, - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.getPayCountryNetworkReset(); - } - } + ], + {cancelable: false} + ) + } else { + Alert.alert( + I18n.t('ERROR_LABEL'), + JSON.stringify(errorActiveCountryList), + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.getActiveCountryReset(); + } + } - ], - { cancelable: false } - ) - } else { - Alert.alert( - I18n.t('ERROR_LABEL'), - JSON.stringify(errorPayCountryNetwork), - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.getPayCountryNetworkReset(); - } - } + ], + {cancelable: false} + ) + } + } + } - ], - { cancelable: false } - ) - } - } - } + renderGetPayCountryNetworkResponse = () => { + const {resultPayCountryNetwork, errorPayCountryNetwork} = this.props; + if (resultPayCountryNetwork !== null) { + if (typeof resultPayCountryNetwork.response !== 'undefined') { + if (resultPayCountryNetwork.response.length > 0) { + this.setState({ + hasLoadActivePayCountryNetworkList: false, + walletActifs: resultPayCountryNetwork.response, + walletActifSelect: resultPayCountryNetwork.response[0].name, + modalVisible: false + }); + } else if (resultPayCountryNetwork.response.length === 0) { + this.setState({ + walletActifs: [], + walletActifSelect: '', + modalVisible: false, + hasLoadActivePayCountryNetworkList: false, + }); + } + } + } - renderEnvoieWalletToWalletResponse = () => { + if (errorPayCountryNetwork !== null) { + if (typeof errorPayCountryNetwork.data !== 'undefined') { + Alert.alert( + I18n.t('ERROR_LABEL'), + errorPayCountryNetwork.data.error, + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.getPayCountryNetworkReset(); + } + } - const { resultEnvoieWalletToCash, errorEnvoieWalletToCash } = this.props; + ], + {cancelable: false} + ) + } else { + Alert.alert( + I18n.t('ERROR_LABEL'), + JSON.stringify(errorPayCountryNetwork), + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.getPayCountryNetworkReset(); + } + } - if (errorEnvoieWalletToCash !== null) { - if (typeof errorEnvoieWalletToCash.data !== 'undefined') { - Alert.alert( - I18n.t("ERROR_TRANSFER"), - errorEnvoieWalletToCash.data.error, - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.envoieUserWalletToCashReset(); - } - } - ], - { cancelable: false } - ) - } - } + ], + {cancelable: false} + ) + } + } + } - if (resultEnvoieWalletToCash !== null) { - if (resultEnvoieWalletToCash.response !== null) { - Alert.alert( - I18n.t("SUCCESS_TRANSFER"), - resultEnvoieWalletToCash.response, - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.envoieUserWalletToCashReset(); - IlinkEmitter.emit("refreshWallet"); - this.props.navigation.pop(); - } - } + renderEnvoieWalletToWalletResponse = () => { - ], - { cancelable: false } - ) - } - } - } + const {resultEnvoieWalletToCash, errorEnvoieWalletToCash} = this.props; - renderDialogGetCommissionResponse = () => { + if (errorEnvoieWalletToCash !== null) { + if (typeof errorEnvoieWalletToCash.data !== 'undefined') { + Alert.alert( + I18n.t("ERROR_TRANSFER"), + errorEnvoieWalletToCash.data.error, + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.envoieUserWalletToCashReset(); + } + } + ], + {cancelable: false} + ) + } + } - const { errorEnvoieWalletToCashGetCommission } = this.props; + if (resultEnvoieWalletToCash !== null) { + if (resultEnvoieWalletToCash.response !== null) { + Alert.alert( + I18n.t("SUCCESS_TRANSFER"), + resultEnvoieWalletToCash.response, + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.envoieUserWalletToCashReset(); + IlinkEmitter.emit("refreshWallet"); + this.props.navigation.pop(); + } + } - if (errorEnvoieWalletToCashGetCommission !== null) { - if (typeof errorEnvoieWalletToCashGetCommission.data !== 'undefined') { - Alert.alert( - I18n.t("ERROR_LABLE"), - errorEnvoieWalletToCashGetCommission.data.error, - [ - { - text: I18n.t("OK"), onPress: () => { - this.props.getCommissionUserWalletToCashReset(); - } - } - ], - { cancelable: false } - ) - } - } + ], + {cancelable: false} + ) + } + } + } - } + renderDialogGetCommissionResponse = () => { - ckeckIfFieldIsOK(champ) { - return (isNil(champ) || isEqual(champ.length, 0)); - } + const {errorEnvoieWalletToCashGetCommission} = this.props; - isMontantValid = () => { - const { montant } = this.state; - if ((parseInt(isEqual(montant, 0)) || montant < 0)) - return { - errorMessage: I18n.t('ENTER_AMOUNT_SUPERIOR_ZEROR'), - isValid: false - }; + if (errorEnvoieWalletToCashGetCommission !== null) { + if (typeof errorEnvoieWalletToCashGetCommission.data !== 'undefined') { + Alert.alert( + I18n.t("ERROR_LABLE"), + errorEnvoieWalletToCashGetCommission.data.error, + [ + { + text: I18n.t("OK"), onPress: () => { + this.props.getCommissionUserWalletToCashReset(); + } + } + ], + {cancelable: false} + ) + } + } - else if (!isNormalInteger(montant)) - return { - errorMessage: I18n.t('ENTER_VALID_AMOUNT'), - isValid: false - }; + } + + ckeckIfFieldIsOK(champ) { + return (isNil(champ) || isEqual(champ.length, 0)); + } + + isMontantValid = () => { + const {montant} = this.state; + if ((parseInt(isEqual(montant, 0)) || montant < 0)) + return { + errorMessage: I18n.t('ENTER_AMOUNT_SUPERIOR_ZEROR'), + isValid: false + }; + + else if (!isNormalInteger(montant)) + return { + errorMessage: I18n.t('ENTER_VALID_AMOUNT'), + isValid: false + }; - else if (montant > parseInt(this.state.comptePrincipal)) - return { - errorMessage: I18n.t('AMOUNT_SUPERIOR_TO_PRINCIPAL_ACCOUNT'), - isValid: false - }; + else if (montant > parseInt(this.state.comptePrincipal)) + return { + errorMessage: I18n.t('AMOUNT_SUPERIOR_TO_PRINCIPAL_ACCOUNT'), + isValid: false + }; - else - return { - errorMessage: '', - isValid: true - }; - } + else + return { + errorMessage: '', + isValid: true + }; + } - modalConfirmTransaction = (data) => { - const commission = data.response.frais; - const montant_net_final = data.response.montant_net_final; - const montant_net_init = data.response.montant_net_init; + modalConfirmTransaction = (data) => { + const commission = data.response.frais; + const montant_net_final = data.response.montant_net_final; + const montant_net_init = data.response.montant_net_init; - console.log("DATA SEND TO CONFIRM DIALOG", data); - return ( + console.log("DATA SEND TO CONFIRM DIALOG", data); + return ( - + - {I18n.t('TRANSACTION_DETAIL')} + {I18n.t('TRANSACTION_DETAIL')} - + - - - - {I18n.t('AMOUNT')} - - - {`${thousands(this.state.montant, ' ')} ${this.state.wallet.currency_code}`} - - - - - {I18n.t('FEES_AND_TAXES')} - - - {`${thousands(commission, ' ')} ${this.state.wallet.currency_code}`} - - - - - - - - {I18n.t('NET_AMOUNT')}: - - - {`${thousands(montant_net_final, ' ')}}`} - - - - + + + + {I18n.t('AMOUNT')} + + + {`${thousands(this.state.montant, ' ')} ${this.state.wallet.currency_code}`} + + + + + {I18n.t('FEES_AND_TAXES')} + + + {`${thousands(commission, ' ')} ${this.state.wallet.currency_code}`} + + + + + + + {I18n.t('NET_AMOUNT')}: + + + {`${thousands(montant_net_final, ' ')}`} + + + + + - { - this.setState({ - isModalConfirmVisible: false - }); - }} /> - { - this.setState({ - isModalConfirmVisible: false, - isDataSubmit: true - }); - this.props.envoieUserWalletToCashAction({ - type: 17, - id_wallet_agent: this.state.wallet.id, - nom_emetteur: this.state.nomsEmetteur, - prenom_emetteur: this.state.prenomsDestinataire, - email_emetteur: this.state.emailEmetteur, - type_document_emetteur: this.state.identityPiecesNameEmetteur, - id_document_emetteur: this.state.numeroIdentiteEmetteur, - final_country: (this.state.paysDestination.filter(element => element.name === this.state.paysDestinationSelect))[0].id, - id_destinataire: this.state.numeroIdentiteEmetteur, - type_document_destinataire: this.state.identityPiecesNameEmetteur, - nom_destinataire: this.state.nomsDestinataire, - prenom_destinataire: this.state.prenomsDestinataire, - id_document_destinataire: this.state.numeroIdentiteDestinataire, - network_destinataire: (this.state.walletActifs.filter(element => element.name === this.state.walletActifSelect))[0].id, - montant: this.state.montant, - password: this.state.password - }); - this.props.getCommissionUserWalletToCashReset(); - }} /> + { + this.setState({ + isModalConfirmVisible: false + }); + }}/> + { + this.setState({ + isModalConfirmVisible: false, + isDataSubmit: true + }); + this.props.envoieUserWalletToCashAction({ + type: 17, + id_wallet_agent: this.state.wallet.id, + nom_emetteur: this.state.nomsEmetteur, + prenom_emetteur: this.state.prenomsDestinataire, + email_emetteur: this.state.emailEmetteur, + type_document_emetteur: this.state.identityPiecesNameEmetteur, + id_document_emetteur: this.state.numeroIdentiteEmetteur, + final_country: (this.state.paysDestination.filter(element => element.name === this.state.paysDestinationSelect))[0].id, + id_destinataire: this.state.numeroIdentiteEmetteur, + type_document_destinataire: this.state.identityPiecesNameEmetteur, + nom_destinataire: this.state.nomsDestinataire, + prenom_destinataire: this.state.prenomsDestinataire, + id_document_destinataire: this.state.numeroIdentiteDestinataire, + network_destinataire: (this.state.walletActifs.filter(element => element.name === this.state.walletActifSelect))[0].id, + montant: this.state.montant, + password: this.state.password + }); + this.props.getCommissionUserWalletToCashReset(); + }}/> - + - ); + ); - } + } - onSubmitNextStep = () => { + onSubmitNextStep = () => { - const { nomsEmetteur, prenomsEmetteur, emailEmetteur, numeroIdentiteEmetteur } = this.state; + const {nomsEmetteur, prenomsEmetteur, emailEmetteur, numeroIdentiteEmetteur} = this.state; - if (this.ckeckIfFieldIsOK(nomsEmetteur)) - this.nomsEmetteurAnim.shake(800); - else if (this.ckeckIfFieldIsOK(prenomsEmetteur)) - this.prenomsEmetteurAnim.shake(800); - else if (this.ckeckIfFieldIsOK(emailEmetteur)) - this.emailEmetteurAnim.shake(800); - else if (this.ckeckIfFieldIsOK(numeroIdentiteEmetteur)) - this.numeroIdentiteEmetteurAnim.shake(800); - else { + if (this.ckeckIfFieldIsOK(nomsEmetteur)) + this.nomsEmetteurAnim.shake(800); + else if (this.ckeckIfFieldIsOK(prenomsEmetteur)) + this.prenomsEmetteurAnim.shake(800); + else if (this.ckeckIfFieldIsOK(emailEmetteur)) + this.emailEmetteurAnim.shake(800); + else if (this.ckeckIfFieldIsOK(numeroIdentiteEmetteur)) + this.numeroIdentiteEmetteurAnim.shake(800); + else { - this.setState({ - triggerNextClick: true, - modalVisible: true, - hasLoadActiveCountryList: true, - hasLoadActivePayCountryNetworkList: true, - displayFirstStep: !this.state.displayFirstStep, - displaySecondStep: !this.state.displaySecondSte - }, () => { - this.props.getActiveCountryAction(); - console.log("ENVOIE WALLET PROPS", this.props); - }); - } - } + this.setState({ + triggerNextClick: true, + modalVisible: true, + hasLoadActiveCountryList: true, + hasLoadActivePayCountryNetworkList: true, + displayFirstStep: !this.state.displayFirstStep, + displaySecondStep: !this.state.displaySecondSte + }, () => { + this.props.getActiveCountryAction(); + console.log("ENVOIE WALLET PROPS", this.props); + }); + } + } - onSubmitCashVersAutreWallet = () => { - const { nomsDestinataire, prenomsDestinataire, montant, password, numeroIdentiteDestinataire } = this.state; + onSubmitCashVersAutreWallet = () => { + const {nomsDestinataire, prenomsDestinataire, montant, password, numeroIdentiteDestinataire} = this.state; - if (this.ckeckIfFieldIsOK(nomsDestinataire)) - this.nomDestinataireAnim.shake(800); - else if (this.ckeckIfFieldIsOK(prenomsDestinataire)) - this.prenomsDestinataireAnim.shake(800); - else if (this.ckeckIfFieldIsOK(numeroIdentiteDestinataire)) - this.identityPiecesDestinataireAnim.shake(800); - else if (this.ckeckIfFieldIsOK(montant) || !this.isMontantValid().isValid) { - console.log("IS MONTANT VALID", this.isMontantValid()) - this.montantAnim.shake(800); - } - else if (this.ckeckIfFieldIsOK(password)) - this.passwordAnim.shake(800); - else { + if (this.ckeckIfFieldIsOK(nomsDestinataire)) + this.nomDestinataireAnim.shake(800); + else if (this.ckeckIfFieldIsOK(prenomsDestinataire)) + this.prenomsDestinataireAnim.shake(800); + else if (this.ckeckIfFieldIsOK(numeroIdentiteDestinataire)) + this.identityPiecesDestinataireAnim.shake(800); + else if (this.ckeckIfFieldIsOK(montant) || !this.isMontantValid().isValid) { + console.log("IS MONTANT VALID", this.isMontantValid()) + this.montantAnim.shake(800); + } else if (this.ckeckIfFieldIsOK(password)) + this.passwordAnim.shake(800); + else { - this.props.getCommissionUserWalletToCashAction({ - type: 17, - id_wallet_agent: this.state.wallet.id, - final_country: (this.state.paysDestination.filter(element => element.name === this.state.paysDestinationSelect))[0].id, - montant: this.state.montant, - }); + this.props.getCommissionUserWalletToCashAction({ + type: 17, + id_wallet_agent: this.state.wallet.id, + final_country: (this.state.paysDestination.filter(element => element.name === this.state.paysDestinationSelect))[0].id, + montant: this.state.montant, + }); - } - this.setState({ - isDataSubmit: false, - triggerSubmitClick: true - }) + } + this.setState({ + isDataSubmit: false, + triggerSubmitClick: true + }) - } + } - renderLoader = () => { - return ( - - ) - } + renderLoader = () => { + return ( + + ) + } - render() { - console.log("STATE", this.state); - const { resultEnvoieWalletToCashGetCommission } = this.props; - return ( - <> - {(this.state.modalVisible || this.props.loadingEnvoieWalletToCashGetCommission || this.props.loadingEnvoieWalletToCash || this.props.loadingCountryByDialCode || this.props.loadingActiveCountryList || this.props.loadingCountryByDialCode) && this.renderLoader()} - {this.state.hasLoadActiveCountryList && this.renderGetActionCountryList()} - {this.state.hasLoadActivePayCountryNetworkList && this.renderGetPayCountryNetworkResponse()} - {this.state.isDataSubmit && this.renderEnvoieWalletToWalletResponse()} - {this.state.triggerSubmitClick && this.renderDialogGetCommissionResponse()} - { - (resultEnvoieWalletToCashGetCommission !== null) && - (typeof resultEnvoieWalletToCashGetCommission.response !== 'undefined') && - this.modalConfirmTransaction(resultEnvoieWalletToCashGetCommission) + render() { + console.log("STATE", this.state); + const {resultEnvoieWalletToCashGetCommission} = this.props; + return ( + <> + {(this.state.modalVisible || this.props.loadingEnvoieWalletToCashGetCommission || this.props.loadingEnvoieWalletToCash || this.props.loadingCountryByDialCode || this.props.loadingActiveCountryList || this.props.loadingCountryByDialCode) && this.renderLoader()} + {this.state.hasLoadActiveCountryList && this.renderGetActionCountryList()} + {this.state.hasLoadActivePayCountryNetworkList && this.renderGetPayCountryNetworkResponse()} + {this.state.isDataSubmit && this.renderEnvoieWalletToWalletResponse()} + {this.state.triggerSubmitClick && this.renderDialogGetCommissionResponse()} + { + (resultEnvoieWalletToCashGetCommission !== null) && + (typeof resultEnvoieWalletToCashGetCommission.response !== 'undefined') && + this.modalConfirmTransaction(resultEnvoieWalletToCashGetCommission) + } + + + {this.state.displayFirstStep && + <> + + {I18n.t('ENVOIE_CASH_TO_CASH')} + + { + this.nomsEmetteurAnim = comp + }}> + { + this.setState({nomsEmetteur}) + }} + style={styles.input} + > + + + + { + this.prenomsEmetteurAnim = comp + }}> + { + this.setState({prenomsEmetteur}) + }} + style={styles.input} + > + + + + { + this.emailEmetteurAnim = comp + }}> + { + this.setState({emailEmetteur}) + }} + style={styles.input} + > + + + + { + this.identityPiecesEmetteurAnim = comp + }} + style={{ + width: responsiveWidth(90), + height: 60, + marginTop: 20, + alignSelf: 'center', + borderRadius: 10, + paddingLeft: 20, + paddingRight: 20, + backgroundColor: 'white' + }}> + { + this.setState({identityPiecesNameEmetteur: value, isDataSubmit: false}); + }} + valueExtractor={(value) => { + return I18n.t(value.name) + }} + labelExtractor={(value) => { + return I18n.t(value.name) + }} + /> + + + { + this.numeroIdentiteEmetteurAnim = comp + }}> + { + this.setState({numeroIdentiteEmetteur}) + }} + style={styles.input} + > + + + + + } - - {this.state.displayFirstStep && - <> + {this.state.displaySecondStep && + <> + { + this.nomDestinataireAnim = comp + }}> + { + this.setState({nomsDestinataire}) + }} + style={styles.input} + > + + - {I18n.t('ENVOIE_CASH_TO_CASH')} + { + this.prenomsDestinataireAnim = comp + }}> + { + this.setState({prenomsDestinataire}) + }} + style={styles.input} + > + + - { this.nomsEmetteurAnim = comp }}> - { - this.setState({ nomsEmetteur }) - }} - style={styles.input} - > - - + { + this.identityPiecesDestinataireAnim = comp + }}> + { + this.setState({numeroIdentiteDestinataire}) + }} + style={styles.input} + > + + - { this.prenomsEmetteurAnim = comp }}> - { - this.setState({ prenomsEmetteur }) - }} - style={styles.input} - > - - - - { this.emailEmetteurAnim = comp }}> - { - this.setState({ emailEmetteur }) - }} - style={styles.input} - > - - - - { this.identityPiecesEmetteurAnim = comp }} - style={{ + { + this.paysDestinationAnim = comp + }} + style={{ width: responsiveWidth(90), height: 60, marginTop: 20, @@ -550,87 +679,41 @@ class EnvoiCashVersCashAgent extends Component { paddingLeft: 20, paddingRight: 20, backgroundColor: 'white' - }}> - { - this.setState({ identityPiecesNameEmetteur: value, isDataSubmit: false }); - }} - valueExtractor={(value) => { return I18n.t(value.name) }} - labelExtractor={(value) => { return I18n.t(value.name) }} - /> - + }}> + { + this.props.getPayCountryNetworkReset(); - { this.numeroIdentiteEmetteurAnim = comp }}> - { - this.setState({ numeroIdentiteEmetteur }) - }} - style={styles.input} - > - - + let countrySelect = data.filter(element => element.name === value); + this.setState({ + paysDestinationSelect: value, + hasLoadActivePayCountryNetworkList: true, + isDataSubmit: false + }, () => { + this.props.getPayCountryNetworkAction({ + id_wallet_agent: this.state.wallet.id, + id_country: countrySelect[0].id + }); + }); + this.props.getCommissionUserWalletToCashReset(); + }} + valueExtractor={(value) => { + return value.name + }} + labelExtractor={(value) => { + return value.name + }} + /> + - - - } - - {this.state.displaySecondStep && - <> - { this.nomDestinataireAnim = comp }}> - { - this.setState({ nomsDestinataire }) - }} - style={styles.input} - > - - - - { this.prenomsDestinataireAnim = comp }}> - { - this.setState({ prenomsDestinataire }) - }} - style={styles.input} - > - - - - { this.identityPiecesDestinataireAnim = comp }}> - { - this.setState({ numeroIdentiteDestinataire }) - }} - style={styles.input} - > - - - - { this.paysDestinationAnim = comp }} - style={{ + { + this.walletActifAnim = comp + }} + style={{ width: responsiveWidth(90), height: 60, marginTop: 20, @@ -639,208 +722,189 @@ class EnvoiCashVersCashAgent extends Component { paddingLeft: 20, paddingRight: 20, backgroundColor: 'white' - }}> - { - this.props.getPayCountryNetworkReset(); + }}> + { + this.setState({ + walletActifSelect: value, + isDataSubmit: false + }); - let countrySelect = data.filter(element => element.name === value); - this.setState({ paysDestinationSelect: value, hasLoadActivePayCountryNetworkList: true, isDataSubmit: false }, () => { - this.props.getPayCountryNetworkAction({ id_wallet_agent: this.state.wallet.id, id_country: countrySelect[0].id }); - }); - this.props.getCommissionUserWalletToCashReset(); - }} - valueExtractor={(value) => { return value.name }} - labelExtractor={(value) => { return value.name }} - /> - + }} + valueExtractor={(value) => { + return value.name + }} + labelExtractor={(value) => { + return value.name + }} + /> + - { this.walletActifAnim = comp }} - style={{ - width: responsiveWidth(90), - height: 60, - marginTop: 20, - alignSelf: 'center', - borderRadius: 10, - paddingLeft: 20, - paddingRight: 20, - backgroundColor: 'white' - }}> - { - this.setState({ - walletActifSelect: value, - isDataSubmit: false - }); + { + this.montantAnim = comp + }}> + { + this.setState({montant}) + }} + style={styles.input} + > + + + { return value.name }} - labelExtractor={(value) => { return value.name }} - /> - + }} + /> + {this.state.wallet.currency_code} + + - { this.montantAnim = comp }}> - { - this.setState({ montant }) - }} - style={styles.input} - > - - - { + this.passwordAnim = comp + }}> + { + this.setState({password}) + }} + style={styles.input} + > + + + - }} - /> - {this.state.wallet.currency_code} - - + + } - { this.passwordAnim = comp }}> - { - this.setState({ password }) - }} - style={styles.input} - > - - - - - - } - - - - ) - } + + + ) + } } const maptStateToProps = state => ({ - loadingCountryByDialCode: state.countryByDialCode.loading, - resultCountryByDialCode: state.countryByDialCode.result, - errorCountryByDialCode: state.countryByDialCode.error, + loadingCountryByDialCode: state.countryByDialCode.loading, + resultCountryByDialCode: state.countryByDialCode.result, + errorCountryByDialCode: state.countryByDialCode.error, - loadingActiveCountryList: state.activeCountryListReducer.loading, - resultActiveCountryList: state.activeCountryListReducer.result, - errorActiveCountryList: state.activeCountryListReducer.error, + loadingActiveCountryList: state.activeCountryListReducer.loading, + resultActiveCountryList: state.activeCountryListReducer.result, + errorActiveCountryList: state.activeCountryListReducer.error, - loadingPayCountryNetwork: state.payCountryNetworkReducer.loading, - resultPayCountryNetwork: state.payCountryNetworkReducer.result, - errorPayCountryNetwork: state.payCountryNetworkReducer.error, + loadingPayCountryNetwork: state.payCountryNetworkReducer.loading, + resultPayCountryNetwork: state.payCountryNetworkReducer.result, + errorPayCountryNetwork: state.payCountryNetworkReducer.error, - loadingEnvoieWalletToCash: state.envoieUserWalletToCashReducer.loading, - resultEnvoieWalletToCash: state.envoieUserWalletToCashReducer.result, - errorEnvoieWalletToCash: state.envoieUserWalletToCashReducer.error, + loadingEnvoieWalletToCash: state.envoieUserWalletToCashReducer.loading, + resultEnvoieWalletToCash: state.envoieUserWalletToCashReducer.result, + errorEnvoieWalletToCash: state.envoieUserWalletToCashReducer.error, - loadingEnvoieWalletToCashGetCommission: state.envoieUserWalletToCashGetCommissionReducer.loading, - resultEnvoieWalletToCashGetCommission: state.envoieUserWalletToCashGetCommissionReducer.result, - errorEnvoieWalletToCashGetCommission: state.envoieUserWalletToCashGetCommissionReducer.error, + loadingEnvoieWalletToCashGetCommission: state.envoieUserWalletToCashGetCommissionReducer.loading, + resultEnvoieWalletToCashGetCommission: state.envoieUserWalletToCashGetCommissionReducer.result, + errorEnvoieWalletToCashGetCommission: state.envoieUserWalletToCashGetCommissionReducer.error, }); const mapDispatchToProps = dispatch => bindActionCreators({ - getActiveCountryByDialCodeAction, - getActiveCountryByDialCodeReset, + getActiveCountryByDialCodeAction, + getActiveCountryByDialCodeReset, - getPayCountryNetworkAction, - getPayCountryNetworkReset, + getPayCountryNetworkAction, + getPayCountryNetworkReset, - getActiveCountryAction, - getActiveCountryReset, + getActiveCountryAction, + getActiveCountryReset, - envoieUserWalletToCashAction, - envoieUserWalletToCashReset, + envoieUserWalletToCashAction, + envoieUserWalletToCashReset, - getCommissionUserWalletToCashAction, - getCommissionUserWalletToCashReset + getCommissionUserWalletToCashAction, + getCommissionUserWalletToCashReset }, dispatch); export default connect(maptStateToProps, mapDispatchToProps)(EnvoiCashVersCashAgent); const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: Color.primaryDarkColor, - }, - textbtnvalide: { - color: 'white', - fontWeight: 'bold' - }, - bigtitle: { - color: 'white', - fontSize: 20, - flex: 1, - fontWeight: 'bold', - textAlign: 'center', - margin: 20, - }, - blockView: { - paddingVertical: 10, - borderBottomWidth: 1 - }, - subbigtitle: { - color: 'white', - fontSize: 17, - textAlign: 'center', - margin: 5, - }, - btnvalide: { - marginTop: 20, - marginLeft: 20, - marginRight: 20, - borderColor: 'transparent', - backgroundColor: Color.accentLightColor, - height: 52 - }, - btnSubmit: { - marginTop: 20, - borderColor: 'transparent', - backgroundColor: Color.accentLightColor, - height: 52, - width: "30%", - marginLeft: 20, - marginRight: 20, - }, - input: { - height: 60, - marginTop: responsiveHeight(2), - marginLeft: responsiveWidth(5), - marginRight: responsiveWidth(5), - borderRadius: 5, - } + container: { + flex: 1, + backgroundColor: Color.primaryDarkColor, + }, + textbtnvalide: { + color: 'white', + fontWeight: 'bold' + }, + bigtitle: { + color: 'white', + fontSize: 20, + flex: 1, + fontWeight: 'bold', + textAlign: 'center', + margin: 20, + }, + blockView: { + paddingVertical: 10, + borderBottomWidth: 1 + }, + subbigtitle: { + color: 'white', + fontSize: 17, + textAlign: 'center', + margin: 5, + }, + btnvalide: { + marginTop: 20, + marginLeft: 20, + marginRight: 20, + borderColor: 'transparent', + backgroundColor: Color.accentLightColor, + height: 52 + }, + btnSubmit: { + marginTop: 20, + borderColor: 'transparent', + backgroundColor: Color.accentLightColor, + height: 52, + width: "30%", + marginLeft: 20, + marginRight: 20, + }, + input: { + height: 60, + marginTop: responsiveHeight(2), + marginLeft: responsiveWidth(5), + marginRight: responsiveWidth(5), + borderRadius: 5, + } }); \ No newline at end of file diff --git a/utils/i18n/fr.json b/utils/i18n/fr.json index 4432e3dd..3789c5f1 100644 --- a/utils/i18n/fr.json +++ b/utils/i18n/fr.json @@ -249,7 +249,7 @@ "DELETE_GROUP": "Supprimer le groupe", "CREATOR": "Créateur", "NOTIFICATIONS": "Notification", - "NO_NOTIFICATION": "Vous n'avez aucune Fnotification", + "NO_NOTIFICATION": "Vous n'avez aucune notification", "CONFIGURATIONS": "Configuration", "LOGOUT": "Déconnexion", "HINT_HOME_SEARCH": " Chercher un lieu, quartier ou ville ",