refresh detail screen

This commit is contained in:
Brice Zele 2020-04-29 10:45:44 +01:00
parent ddc2a8b8e5
commit f324f825ee
10 changed files with 99 additions and 54 deletions

View File

@ -7,7 +7,8 @@ import {
WALLET_HISTORY_ERROR, WALLET_HISTORY_ERROR,
WALLET_TRANSFER_COMMISSION_PENDING, WALLET_TRANSFER_COMMISSION_PENDING,
WALLET_TRANSFER_COMMISSION_SUCCESS, WALLET_TRANSFER_COMMISSION_SUCCESS,
WALLET_TRANSFER_COMMISSION_ERROR WALLET_TRANSFER_COMMISSION_ERROR,
WALLET_TRANSFER_COMMISSION_RESET
} from "../types/WalletType"; } from "../types/WalletType";
@ -43,6 +44,10 @@ export const fetchWalletTransferCommissionPending = () => ({
type: WALLET_TRANSFER_COMMISSION_PENDING type: WALLET_TRANSFER_COMMISSION_PENDING
}); });
export const walletTransferCommissionReset = () => ({
type: WALLET_TRANSFER_COMMISSION_RESET
});
export const fetchWalletTransferCommissionSuccess = (res) => ({ export const fetchWalletTransferCommissionSuccess = (res) => ({
type: WALLET_TRANSFER_COMMISSION_SUCCESS, type: WALLET_TRANSFER_COMMISSION_SUCCESS,
result: res, result: res,

View File

@ -1,4 +1,4 @@
import { WALLET_TRANSFER_COMMISSION_PENDING, WALLET_TRANSFER_COMMISSION_SUCCESS, WALLET_TRANSFER_COMMISSION_ERROR } from "../types/WalletType"; import { WALLET_TRANSFER_COMMISSION_PENDING, WALLET_TRANSFER_COMMISSION_SUCCESS, WALLET_TRANSFER_COMMISSION_ERROR, WALLET_TRANSFER_COMMISSION_RESET } from "../types/WalletType";
const initialState = { const initialState = {
loadingTransferCommission: false, loadingTransferCommission: false,
@ -25,6 +25,8 @@ export default (state = initialState, action) => {
errorTransferCommission: action.result errorTransferCommission: action.result
} }
case WALLET_TRANSFER_COMMISSION_RESET: return initialState;
default: { default: {
return state; return state;
} }

View File

@ -9,3 +9,4 @@ export const WALLET_HISTORY_ERROR = 'WALLET_HISTORY_ERROR';
export const WALLET_TRANSFER_COMMISSION_PENDING = 'WALLET_TRANSFER_COMMISSION_PENDING'; export const WALLET_TRANSFER_COMMISSION_PENDING = 'WALLET_TRANSFER_COMMISSION_PENDING';
export const WALLET_TRANSFER_COMMISSION_SUCCESS = 'WALLET_TRANSFER_COMMISSION_SUCCESS'; export const WALLET_TRANSFER_COMMISSION_SUCCESS = 'WALLET_TRANSFER_COMMISSION_SUCCESS';
export const WALLET_TRANSFER_COMMISSION_ERROR = 'WALLET_TRANSFER_COMMISSION_ERROR'; export const WALLET_TRANSFER_COMMISSION_ERROR = 'WALLET_TRANSFER_COMMISSION_ERROR';
export const WALLET_TRANSFER_COMMISSION_RESET = 'WALLET_TRANSFER_COMMISSION_RESET';

View File

@ -237,7 +237,7 @@ class WalletDepot extends Component {
displayCardError: true displayCardError: true
}) })
} }
this.setState({ isSubmitClick: true }) this.setState({ isSubmitClick: !this.state.isSubmitClick })
} }
isHasError = () => { isHasError = () => {

View File

@ -15,7 +15,8 @@ import { Typography, FontWeight } from '../../config/typography';
import { responsiveHeight, responsiveWidth, } from 'react-native-responsive-dimensions'; import { responsiveHeight, responsiveWidth, } from 'react-native-responsive-dimensions';
import getWalletActivated from '../../webservice/WalletApi'; import getWalletActivated from '../../webservice/WalletApi';
import getWalletTransactionHistory from '../../webservice/WalletTransactionHistoryApi'; import getWalletTransactionHistory from '../../webservice/WalletTransactionHistoryApi';
import transferCommissionAction from '../../webservice/WalletTransferCommission'; import { transferCommissionAction } from '../../webservice/WalletTransferCommission';
import { resetCommissionReducer } from '../../webservice/WalletTransferCommission';
import Dialog, { DialogContent, DialogTitle, DialogFooter, DialogButton } from 'react-native-popup-dialog'; import Dialog, { DialogContent, DialogTitle, DialogFooter, DialogButton } from 'react-native-popup-dialog';
import { baseUrl } from '../../webservice/IlinkConstants'; import { baseUrl } from '../../webservice/IlinkConstants';
let moment = require('moment-timezone'); let moment = require('moment-timezone');
@ -46,9 +47,11 @@ class WalletDetail extends Component {
heightHeader: Utils.heightHeader(), heightHeader: Utils.heightHeader(),
isModalConfirmVisible: false, isModalConfirmVisible: false,
wallet: null, wallet: null,
triggerTransferCommission: false triggerTransferCommission: false,
loading: false,
}; };
this.renderContent = null;
slugify.extend({ '+': 'plus' }); slugify.extend({ '+': 'plus' });
this.scrollY = new Animated.Value(0); this.scrollY = new Animated.Value(0);
@ -135,6 +138,16 @@ class WalletDetail extends Component {
} }
} }
componentWillReceiveProps(nextProps) {
if (nextProps.loading || nextProps.loadingTransferCommission)
this.setState({
loading: true
})
else
this.setState({
loading: false
})
}
isEmptyObject = (obj) => { isEmptyObject = (obj) => {
for (let prop in obj) { for (let prop in obj) {
@ -190,9 +203,8 @@ class WalletDetail extends Component {
refresh = () => { refresh = () => {
const { agentId, wallet } = this.props.navigation.state.params; const { agentId, wallet } = this.props.navigation.state.params;
if (typeof agentId !== "undefined") { if (typeof agentId === "undefined")
this.props.getWalletActivated(wallet.agentId); this.props.getWalletActivated(wallet.agentId);
}
else else
this.props.getWalletActivated(agentId); this.props.getWalletActivated(agentId);
} }
@ -372,9 +384,9 @@ class WalletDetail extends Component {
!this.isEmptyObject(wallet) ? !this.isEmptyObject(wallet) ?
(<> (<>
{this.state.triggerTransferCommission && this.renderDialogTransferCommissionResponse()} {this.state.triggerTransferCommission && this.renderDialogTransferCommissionResponse()}
{this.props.loading ? {this.state.loading ?
<View <View
style={{ position: "absolute", zIndex: 1, backgroundColor: "#00000050", width: this.props.loading ? responsiveWidth(100) : 0, height: this.props.loading ? responsiveHeight(100) : 0, flex: 1, justifyContent: 'center', alignItems: 'center' }}> style={{ position: "absolute", zIndex: 1, backgroundColor: "#00000050", width: this.state.loading ? responsiveWidth(100) : 0, height: this.state.loading ? responsiveHeight(100) : 0, flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text style={{ fontSize: 20, color: 'white', fontWeight: 'bold' }}>{I18n.t("LOADING_DOTS")}</Text> <Text style={{ fontSize: 20, color: 'white', fontWeight: 'bold' }}>{I18n.t("LOADING_DOTS")}</Text>
</View> : null </View> : null
} }
@ -625,7 +637,7 @@ class WalletDetail extends Component {
this.props.transferCommissionAction(this.state.wallet.id); this.props.transferCommissionAction(this.state.wallet.id);
this.refresh(); this.refresh();
this.setState({ this.setState({
triggerTransferCommission: !this.state.triggerTransferCommission triggerTransferCommission: true
}); });
} }
} }
@ -638,35 +650,21 @@ class WalletDetail extends Component {
renderDialogTransferCommissionResponse = () => { renderDialogTransferCommissionResponse = () => {
const { resultTransferCommission, errorTransferCommission } = this.props; const { resultTransferCommission, errorTransferCommission } = this.props;
console.log("resultTransferCommission", resultTransferCommission);
console.log("errorTransferCommission", errorTransferCommission);
if (errorTransferCommission !== null) { if (errorTransferCommission !== null) {
if (typeof errorTransferCommission.data !== 'undefined') { if (typeof errorTransferCommission.data !== 'undefined') {
Alert.alert( Alert.alert(
I18n.t("ERROR_LABLE"), I18n.t("ERROR_TRANSFER_COMMISSION"),
errorTransferCommission.data.error errorTransferCommission.data.error,
,
[ [
{ {
text: I18n.t("OK"), onPress: () => { text: I18n.t("OK"), onPress: () => {
this.props.resetCommissionReducer();
} }
} }
],
{ cancelable: false }
)
}
else {
Alert.alert(
I18n.t("ERROR_LABLE"),
errorTransferCommission
,
[
{
text: I18n.t("OK"), onPress: () => {
}
}
], ],
{ cancelable: false } { cancelable: false }
) )
@ -677,11 +675,11 @@ class WalletDetail extends Component {
if (resultTransferCommission.response !== null) { if (resultTransferCommission.response !== null) {
Alert.alert( Alert.alert(
I18n.t("SUCCESS"), I18n.t("SUCCESS"),
resultTransferCommission.response, I18n.t("COMMISSION_TRANSFER_SUCCESS"),
[ [
{ {
text: I18n.t("OK"), onPress: () => { text: I18n.t("OK"), onPress: () => {
this.props.resetCommissionReducer();
} }
} }
@ -692,14 +690,37 @@ class WalletDetail extends Component {
} }
} }
render() { getWalletParam = () => {
console.log('Wallet Detail props', this.props); const { result } = this.props;
const isHomeRootView = this.props.navigation.state.params.hasOwnProperty('agentId');
if (!isHomeRootView)
return this.props.navigation.state.params.wallet;
else
return this.props.response;
}
render() {
console.log("THE PROPS", this.props);
const { resultTransaction, resultTransferCommission } = this.props;
const isHomeRootView = this.props.navigation.state.params.hasOwnProperty('agentId'); const isHomeRootView = this.props.navigation.state.params.hasOwnProperty('agentId');
console.log("WALLET PARAMS", this.props.navigation.state.params.wallet);
return ( return (
!isHomeRootView ? <>
{
!isHomeRootView ? (
(this.props.loading || this.props.loadingTransferCommission) ?
this.renderDetailWallet(this.getWalletParam()) : (
((this.props.result !== null)) ?
this.renderDetailWallet(this.props.result.response) :
this.renderDetailWallet(this.props.navigation.state.params.wallet) this.renderDetailWallet(this.props.navigation.state.params.wallet)
:
)
) :
((this.props.loading || this.props.loadingTransferCommission) ? ((this.props.loading || this.props.loadingTransferCommission) ?
this.renderLoader() : this.renderLoader() :
( (
@ -707,6 +728,10 @@ class WalletDetail extends Component {
this.renderDetailWallet(this.props.result.response) this.renderDetailWallet(this.props.result.response)
) )
) )
}
</>
); );
} }
} }
@ -729,7 +754,8 @@ const mapStateToProps = state => ({
const mapDispatchToProps = dispatch => bindActionCreators({ const mapDispatchToProps = dispatch => bindActionCreators({
getWalletActivated, getWalletActivated,
getWalletTransactionHistory, getWalletTransactionHistory,
transferCommissionAction transferCommissionAction,
resetCommissionReducer
}, dispatch); }, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(WalletDetail); export default connect(mapStateToProps, mapDispatchToProps)(WalletDetail);

View File

@ -75,7 +75,6 @@ class WalletRetrait extends Component {
} }
onCreditCardChange = (form) => { onCreditCardChange = (form) => {
console.log(form);
this.setState({ this.setState({
creditCardInput: form, creditCardInput: form,
displayCardError: false displayCardError: false
@ -174,7 +173,7 @@ class WalletRetrait extends Component {
numCarte: parseInt((this.state.creditCardInput.values.number).replace(/ /g, ' ')), numCarte: parseInt((this.state.creditCardInput.values.number).replace(/ /g, ' ')),
cvv: this.state.creditCardInput.values.cvc, cvv: this.state.creditCardInput.values.cvc,
expiration_date: this.state.creditCardInput.values.expiry, expiration_date: this.state.creditCardInput.values.expiry,
type: "credit", type: "debit",
montant: this.state.montant, montant: this.state.montant,
id_wallet: this.state.id id_wallet: this.state.id
}); });
@ -223,6 +222,10 @@ class WalletRetrait extends Component {
const { creditCardInput } = this.state; const { creditCardInput } = this.state;
if (this.isMontantValid().isValid && creditCardInput.valid) { if (this.isMontantValid().isValid && creditCardInput.valid) {
console.log("Is Montant Valid", this.isMontantValid.isValid);
console.log("creditCardInput Valid", creditCardInput.valid);
this.setState({ this.setState({
numCarte: parseInt((creditCardInput.values.number).replace(/ /g, ' ')), numCarte: parseInt((creditCardInput.values.number).replace(/ /g, ' ')),
cvv: creditCardInput.values.cvc, cvv: creditCardInput.values.cvc,

View File

@ -54,6 +54,7 @@
"DEMAND_SEND": "Demand send", "DEMAND_SEND": "Demand send",
"WITHDRAWAL_DESCRIPTION": "Make a withdrawal", "WITHDRAWAL_DESCRIPTION": "Make a withdrawal",
"COMMISSION_ACCOUNT_TITLE": "Commission account", "COMMISSION_ACCOUNT_TITLE": "Commission account",
"COMMISSION_TRANSFER_SUCCESS": "Commissions have been transferred to the main account",
"CONFIRM": "Confirm", "CONFIRM": "Confirm",
"CONFIRM_TRANSFER_COMMISSION": "Confirm commission transfer", "CONFIRM_TRANSFER_COMMISSION": "Confirm commission transfer",
"CREATION_DATE": "Creation date", "CREATION_DATE": "Creation date",
@ -138,6 +139,7 @@
}, },
"ERROR_FILTER": "Error occurred during the filter", "ERROR_FILTER": "Error occurred during the filter",
"ERROR_LABLE": "Erreur", "ERROR_LABLE": "Erreur",
"ERROR_TRANSFER_COMMISSION": "Commissions transfer error",
"ERROR_FILTER_TEXT": "Problem encountered while filtering.", "ERROR_FILTER_TEXT": "Problem encountered while filtering.",
"YOUR_THERE": "You are here", "YOUR_THERE": "You are here",
"FILTER": "Filter", "FILTER": "Filter",

View File

@ -59,6 +59,7 @@
"CONFIRM": "Confirmer", "CONFIRM": "Confirmer",
"CONFIRM_TRANSFER_COMMISSION": "Confirmer le transfert des commissions", "CONFIRM_TRANSFER_COMMISSION": "Confirmer le transfert des commissions",
"PRINCIPAL_ACCOUNT_TITLE": "Cpt. principal", "PRINCIPAL_ACCOUNT_TITLE": "Cpt. principal",
"COMMISSION_TRANSFER_SUCCESS": "Les commissions ont été transférées vers le compte principal",
"TRANSACTIONS": "Transactions", "TRANSACTIONS": "Transactions",
"TRANSACTION_HISTORY": "Historique des transactions", "TRANSACTION_HISTORY": "Historique des transactions",
"WITHDRAWAL_TRANSACTION_HISTORY_DESCRIPTION": "Retrait de", "WITHDRAWAL_TRANSACTION_HISTORY_DESCRIPTION": "Retrait de",
@ -140,6 +141,7 @@
}, },
"ERROR_FILTER": "Erreur survenue lors du filtre", "ERROR_FILTER": "Erreur survenue lors du filtre",
"ERROR_LABLE": "Erreur", "ERROR_LABLE": "Erreur",
"ERROR_TRANSFER_COMMISSION": "Erreur de transfert des commissions",
"ERROR_FILTER_TEXT": "Probleme rencontré lors du filtrage.", "ERROR_FILTER_TEXT": "Probleme rencontré lors du filtrage.",
"YOUR_THERE": "Vous êtes ici", "YOUR_THERE": "Vous êtes ici",
"FILTER": "Filtrer", "FILTER": "Filtrer",

View File

@ -1,6 +1,6 @@
export const isDebugMode = false export const isDebugMode = false
//base url test //base url test
//const baseUrl = "https://ilink-app.com/mobilebackendbeta" //export const baseUrl = "https://ilink-app.com/mobilebackendbeta"
//base url production //base url production
//export const baseUrl = "https://ilink-app.com/mobilebackend"; //export const baseUrl = "https://ilink-app.com/mobilebackend";
//export const baseUrl = "https://test.ilink-app.com/mobilebackendtest"; //export const baseUrl = "https://test.ilink-app.com/mobilebackendtest";

View File

@ -2,9 +2,9 @@
import { transferCommission } from "./IlinkConstants"; import { transferCommission } from "./IlinkConstants";
import { store } from "../redux/store"; import { store } from "../redux/store";
import axios from "axios"; import axios from "axios";
import { fetchWalletTransferCommissionPending, fetchWalletTransferCommissionSuccess, fetchWalletTransferCommssionError } from "../redux/actions/WalletActions"; import { fetchWalletTransferCommissionPending, fetchWalletTransferCommissionSuccess, fetchWalletTransferCommssionError, walletTransferCommissionReset } from "../redux/actions/WalletActions";
const transferCommissionAction = (walletID) => { export const transferCommissionAction = (walletID) => {
const auth = store.getState().authKeyReducer; const auth = store.getState().authKeyReducer;
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : ''; const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
@ -36,4 +36,8 @@ const transferCommissionAction = (walletID) => {
} }
} }
export default transferCommissionAction; export const resetCommissionReducer = () => {
return dispatch => {
dispatch(walletTransferCommissionReset());
}
}