refresh detail screen
This commit is contained in:
parent
ddc2a8b8e5
commit
f324f825ee
|
@ -7,7 +7,8 @@ import {
|
|||
WALLET_HISTORY_ERROR,
|
||||
WALLET_TRANSFER_COMMISSION_PENDING,
|
||||
WALLET_TRANSFER_COMMISSION_SUCCESS,
|
||||
WALLET_TRANSFER_COMMISSION_ERROR
|
||||
WALLET_TRANSFER_COMMISSION_ERROR,
|
||||
WALLET_TRANSFER_COMMISSION_RESET
|
||||
} from "../types/WalletType";
|
||||
|
||||
|
||||
|
@ -43,6 +44,10 @@ export const fetchWalletTransferCommissionPending = () => ({
|
|||
type: WALLET_TRANSFER_COMMISSION_PENDING
|
||||
});
|
||||
|
||||
export const walletTransferCommissionReset = () => ({
|
||||
type: WALLET_TRANSFER_COMMISSION_RESET
|
||||
});
|
||||
|
||||
export const fetchWalletTransferCommissionSuccess = (res) => ({
|
||||
type: WALLET_TRANSFER_COMMISSION_SUCCESS,
|
||||
result: res,
|
||||
|
|
|
@ -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 = {
|
||||
loadingTransferCommission: false,
|
||||
|
@ -25,6 +25,8 @@ export default (state = initialState, action) => {
|
|||
errorTransferCommission: action.result
|
||||
}
|
||||
|
||||
case WALLET_TRANSFER_COMMISSION_RESET: return initialState;
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -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_SUCCESS = 'WALLET_TRANSFER_COMMISSION_SUCCESS';
|
||||
export const WALLET_TRANSFER_COMMISSION_ERROR = 'WALLET_TRANSFER_COMMISSION_ERROR';
|
||||
export const WALLET_TRANSFER_COMMISSION_RESET = 'WALLET_TRANSFER_COMMISSION_RESET';
|
|
@ -237,7 +237,7 @@ class WalletDepot extends Component {
|
|||
displayCardError: true
|
||||
})
|
||||
}
|
||||
this.setState({ isSubmitClick: true })
|
||||
this.setState({ isSubmitClick: !this.state.isSubmitClick })
|
||||
}
|
||||
|
||||
isHasError = () => {
|
||||
|
|
|
@ -15,7 +15,8 @@ import { Typography, FontWeight } from '../../config/typography';
|
|||
import { responsiveHeight, responsiveWidth, } from 'react-native-responsive-dimensions';
|
||||
import getWalletActivated from '../../webservice/WalletApi';
|
||||
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 { baseUrl } from '../../webservice/IlinkConstants';
|
||||
let moment = require('moment-timezone');
|
||||
|
@ -46,9 +47,11 @@ class WalletDetail extends Component {
|
|||
heightHeader: Utils.heightHeader(),
|
||||
isModalConfirmVisible: false,
|
||||
wallet: null,
|
||||
triggerTransferCommission: false
|
||||
triggerTransferCommission: false,
|
||||
loading: false,
|
||||
};
|
||||
|
||||
this.renderContent = null;
|
||||
slugify.extend({ '+': 'plus' });
|
||||
|
||||
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) => {
|
||||
for (let prop in obj) {
|
||||
|
@ -190,9 +203,8 @@ class WalletDetail extends Component {
|
|||
|
||||
refresh = () => {
|
||||
const { agentId, wallet } = this.props.navigation.state.params;
|
||||
if (typeof agentId !== "undefined") {
|
||||
if (typeof agentId === "undefined")
|
||||
this.props.getWalletActivated(wallet.agentId);
|
||||
}
|
||||
else
|
||||
this.props.getWalletActivated(agentId);
|
||||
}
|
||||
|
@ -372,9 +384,9 @@ class WalletDetail extends Component {
|
|||
!this.isEmptyObject(wallet) ?
|
||||
(<>
|
||||
{this.state.triggerTransferCommission && this.renderDialogTransferCommissionResponse()}
|
||||
{this.props.loading ?
|
||||
{this.state.loading ?
|
||||
<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>
|
||||
</View> : null
|
||||
}
|
||||
|
@ -625,7 +637,7 @@ class WalletDetail extends Component {
|
|||
this.props.transferCommissionAction(this.state.wallet.id);
|
||||
this.refresh();
|
||||
this.setState({
|
||||
triggerTransferCommission: !this.state.triggerTransferCommission
|
||||
triggerTransferCommission: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -638,35 +650,21 @@ class WalletDetail extends Component {
|
|||
|
||||
renderDialogTransferCommissionResponse = () => {
|
||||
const { resultTransferCommission, errorTransferCommission } = this.props;
|
||||
|
||||
console.log("resultTransferCommission", resultTransferCommission);
|
||||
console.log("errorTransferCommission", errorTransferCommission);
|
||||
|
||||
if (errorTransferCommission !== null) {
|
||||
if (typeof errorTransferCommission.data !== 'undefined') {
|
||||
Alert.alert(
|
||||
I18n.t("ERROR_LABLE"),
|
||||
errorTransferCommission.data.error
|
||||
,
|
||||
I18n.t("ERROR_TRANSFER_COMMISSION"),
|
||||
errorTransferCommission.data.error,
|
||||
[
|
||||
{
|
||||
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 }
|
||||
)
|
||||
|
@ -677,11 +675,11 @@ class WalletDetail extends Component {
|
|||
if (resultTransferCommission.response !== null) {
|
||||
Alert.alert(
|
||||
I18n.t("SUCCESS"),
|
||||
resultTransferCommission.response,
|
||||
I18n.t("COMMISSION_TRANSFER_SUCCESS"),
|
||||
[
|
||||
{
|
||||
text: I18n.t("OK"), onPress: () => {
|
||||
|
||||
this.props.resetCommissionReducer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -692,21 +690,48 @@ class WalletDetail extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log('Wallet Detail props', this.props);
|
||||
getWalletParam = () => {
|
||||
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');
|
||||
console.log("WALLET PARAMS", this.props.navigation.state.params.wallet);
|
||||
return (
|
||||
!isHomeRootView ?
|
||||
this.renderDetailWallet(this.props.navigation.state.params.wallet)
|
||||
:
|
||||
((this.props.loading || this.props.loadingTransferCommission) ?
|
||||
this.renderLoader() :
|
||||
(
|
||||
this.props.result !== null &&
|
||||
this.renderDetailWallet(this.props.result.response)
|
||||
)
|
||||
)
|
||||
<>
|
||||
{
|
||||
!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.props.loading || this.props.loadingTransferCommission) ?
|
||||
this.renderLoader() :
|
||||
(
|
||||
this.props.result !== null &&
|
||||
this.renderDetailWallet(this.props.result.response)
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -729,7 +754,8 @@ const mapStateToProps = state => ({
|
|||
const mapDispatchToProps = dispatch => bindActionCreators({
|
||||
getWalletActivated,
|
||||
getWalletTransactionHistory,
|
||||
transferCommissionAction
|
||||
transferCommissionAction,
|
||||
resetCommissionReducer
|
||||
}, dispatch);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(WalletDetail);
|
||||
|
|
|
@ -75,7 +75,6 @@ class WalletRetrait extends Component {
|
|||
}
|
||||
|
||||
onCreditCardChange = (form) => {
|
||||
console.log(form);
|
||||
this.setState({
|
||||
creditCardInput: form,
|
||||
displayCardError: false
|
||||
|
@ -174,7 +173,7 @@ class WalletRetrait extends Component {
|
|||
numCarte: parseInt((this.state.creditCardInput.values.number).replace(/ /g, ' ')),
|
||||
cvv: this.state.creditCardInput.values.cvc,
|
||||
expiration_date: this.state.creditCardInput.values.expiry,
|
||||
type: "credit",
|
||||
type: "debit",
|
||||
montant: this.state.montant,
|
||||
id_wallet: this.state.id
|
||||
});
|
||||
|
@ -223,6 +222,10 @@ class WalletRetrait extends Component {
|
|||
const { creditCardInput } = this.state;
|
||||
|
||||
if (this.isMontantValid().isValid && creditCardInput.valid) {
|
||||
|
||||
console.log("Is Montant Valid", this.isMontantValid.isValid);
|
||||
console.log("creditCardInput Valid", creditCardInput.valid);
|
||||
|
||||
this.setState({
|
||||
numCarte: parseInt((creditCardInput.values.number).replace(/ /g, ' ')),
|
||||
cvv: creditCardInput.values.cvc,
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
"DEMAND_SEND": "Demand send",
|
||||
"WITHDRAWAL_DESCRIPTION": "Make a withdrawal",
|
||||
"COMMISSION_ACCOUNT_TITLE": "Commission account",
|
||||
"COMMISSION_TRANSFER_SUCCESS": "Commissions have been transferred to the main account",
|
||||
"CONFIRM": "Confirm",
|
||||
"CONFIRM_TRANSFER_COMMISSION": "Confirm commission transfer",
|
||||
"CREATION_DATE": "Creation date",
|
||||
|
@ -138,6 +139,7 @@
|
|||
},
|
||||
"ERROR_FILTER": "Error occurred during the filter",
|
||||
"ERROR_LABLE": "Erreur",
|
||||
"ERROR_TRANSFER_COMMISSION": "Commissions transfer error",
|
||||
"ERROR_FILTER_TEXT": "Problem encountered while filtering.",
|
||||
"YOUR_THERE": "You are here",
|
||||
"FILTER": "Filter",
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
"CONFIRM": "Confirmer",
|
||||
"CONFIRM_TRANSFER_COMMISSION": "Confirmer le transfert des commissions",
|
||||
"PRINCIPAL_ACCOUNT_TITLE": "Cpt. principal",
|
||||
"COMMISSION_TRANSFER_SUCCESS": "Les commissions ont été transférées vers le compte principal",
|
||||
"TRANSACTIONS": "Transactions",
|
||||
"TRANSACTION_HISTORY": "Historique des transactions",
|
||||
"WITHDRAWAL_TRANSACTION_HISTORY_DESCRIPTION": "Retrait de",
|
||||
|
@ -140,6 +141,7 @@
|
|||
},
|
||||
"ERROR_FILTER": "Erreur survenue lors du filtre",
|
||||
"ERROR_LABLE": "Erreur",
|
||||
"ERROR_TRANSFER_COMMISSION": "Erreur de transfert des commissions",
|
||||
"ERROR_FILTER_TEXT": "Probleme rencontré lors du filtrage.",
|
||||
"YOUR_THERE": "Vous êtes ici",
|
||||
"FILTER": "Filtrer",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export const isDebugMode = false
|
||||
//base url test
|
||||
//const baseUrl = "https://ilink-app.com/mobilebackendbeta"
|
||||
//export const baseUrl = "https://ilink-app.com/mobilebackendbeta"
|
||||
//base url production
|
||||
//export const baseUrl = "https://ilink-app.com/mobilebackend";
|
||||
//export const baseUrl = "https://test.ilink-app.com/mobilebackendtest";
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
import { transferCommission } from "./IlinkConstants";
|
||||
import { store } from "../redux/store";
|
||||
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 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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue