From e8c621331dd8cfc8a55b46b416da71089890de2a Mon Sep 17 00:00:00 2001 From: Brice Zele Date: Sun, 4 Oct 2020 16:31:16 +0100 Subject: [PATCH] Historique demande cautionnnes agent ok --- screens/wallet/WalletOptionSelect.js | 287 ++++++++++++++------------- webservice/IlinkConstants.js | 1 + webservice/user/NanoCreditApi.js | 6 +- 3 files changed, 153 insertions(+), 141 deletions(-) diff --git a/screens/wallet/WalletOptionSelect.js b/screens/wallet/WalletOptionSelect.js index adacbb71..d4cb002c 100644 --- a/screens/wallet/WalletOptionSelect.js +++ b/screens/wallet/WalletOptionSelect.js @@ -61,7 +61,9 @@ class WalletOptionSelect extends Component { if (user !== undefined) { if (typeof user.category === 'undefined') { this.props.getNanoCreditAccountAction(user.id); - this.props.getNanoCreditUserHistoryAction(user.id); + this.props.getNanoCreditUserHistoryAction(user.id, true); + } else { + this.props.getNanoCreditUserHistoryAction(user.agentId, false); } this.setState({ user }); } @@ -75,8 +77,12 @@ class WalletOptionSelect extends Component { readUser().then((user) => { if (user) { if (user !== undefined) { - this.props.getNanoCreditUserHistoryAction(user.id); - this.props.getNanoCreditAccountAction(user.id); + if (typeof user.category === 'undefined') { + this.props.getNanoCreditAccountAction(user.id); + this.props.getNanoCreditUserHistoryAction(user.id, true); + } else { + this.props.getNanoCreditUserHistoryAction(user.agentId, false); + } } } }); @@ -336,15 +342,11 @@ class WalletOptionSelect extends Component { } - style={{ paddingRight: 10, width: 120, borderTopRightRadius: 0, borderBottomRightRadius: 0, borderRightWidth: 1, borderRightColor: Color.whiteColor }} + style={{ paddingRight: 10, width: 120, borderRightWidth: 1, borderRightColor: Color.whiteColor }} primary onPress={() => { - - }}>{I18n.t('SAVINGS')} - - } primary - style={{ width: 110, borderTopLeftRadius: 0, borderBottomLeftRadius: 0, }}> - {I18n.t('CREDIT')} + this._scrollView.scrollToEnd(); + }}>{I18n.t('HISTORY')} @@ -411,7 +413,7 @@ class WalletOptionSelect extends Component { return ( { this.setState({ displayModalHistory: true, historyItemDetail: item }) }} style={[styles.contentService, { borderBottomColor: Color.primaryColor }]}> { - Object.keys(omit(item, ['id', 'type', 'id_epargne', 'id_demande', 'duree_mois', 'taxe', '', 'date_fin', 'date_cassation', 'etat', 'id_user', 'id_network', 'user', 'partiellement_rembourse', 'user_phone', 'type_caution', 'interet', 'date_remboursement_prevu', 'date_remboursement', 'id_wallet_agent', 'retrait_cash', 'codeParrain', 'agent', 'montant_rembourse',])).map((element, i) => ( + Object.keys(omit(item, ['id', 'type', 'id_epargne', 'date_demande', 'id_demande', 'duree_mois', 'taxe', '', 'date_fin', 'date_cassation', 'etat', 'id_user', 'id_network', 'user', 'partiellement_rembourse', 'user_phone', 'type_caution', 'interet', 'date_remboursement_prevu', 'date_remboursement', 'id_wallet_agent', 'retrait_cash', 'codeParrain', 'agent', 'montant_rembourse', ''])).map((element, i) => ( { @@ -440,9 +442,9 @@ class WalletOptionSelect extends Component { Détail de l'historique - - { - isEqual(historyItemDetail.type_historique, 'N') ? + { + isEqual(historyItemDetail.type_historique, 'N') ? + @@ -557,102 +559,100 @@ class WalletOptionSelect extends Component { - - : - - - - Type - - - {displayTransactionType(this.state.historyItemDetail.type_historique)} - + + : + + + + Type - - - {I18n.t('ID_DEMAND')} - - - {this.state.historyItemDetail.id_demande} - - - - - {I18n.t('STATUS')} - - - {this.state.historyItemDetail.etat} - - - - - {I18n.t('DEMAND_DURATION_IN_MONTH')} - - - {this.state.historyItemDetail.duree_mois} - - - - - Type - - - {this.state.historyItemDetail.type} - - - - - {I18n.t('AMOUNT')} - - - {this.state.historyItemDetail.montant + ' ' + this.state.wallet.currency_code} - - - - - {I18n.t('TAXES')} - - - {this.state.historyItemDetail.taxe + ' ' + this.state.wallet.currency_code} - - - - - {I18n.t('INTERET')} - - - {this.state.historyItemDetail.interet + ' ' + this.state.wallet.currency_code} - - - - - {I18n.t('CREATION_DATE')} - - - {this.state.historyItemDetail.date_creation} - - - - - {I18n.t('FINAL_DATE')} - - - {this.state.historyItemDetail.date_fin} - - - - - {I18n.t('CASSATION_DATE')} - - - {this.state.historyItemDetail.date_cassation} - + + {displayTransactionType(this.state.historyItemDetail.type_historique)} + + + {I18n.t('ID_DEMAND')} + + + {this.state.historyItemDetail.id_demande} + + + + + {I18n.t('STATUS')} + + + {this.state.historyItemDetail.etat} + + + + + {I18n.t('DEMAND_DURATION_IN_MONTH')} + + + {this.state.historyItemDetail.duree_mois} + + + + + Type + + + {this.state.historyItemDetail.type} + + + + + {I18n.t('AMOUNT')} + + + {this.state.historyItemDetail.montant + ' ' + this.state.wallet.currency_code} + + + + + {I18n.t('TAXES')} + + + {this.state.historyItemDetail.taxe + ' ' + this.state.wallet.currency_code} + + + + + {I18n.t('INTERET')} + + + {this.state.historyItemDetail.interet + ' ' + this.state.wallet.currency_code} + + + + + {I18n.t('CREATION_DATE')} + + + {this.state.historyItemDetail.date_creation} + + + + + {I18n.t('FINAL_DATE')} + + + {this.state.historyItemDetail.date_fin} + + + + + {I18n.t('CASSATION_DATE')} + + + {this.state.historyItemDetail.date_cassation} + + + + } - } - - { this.setState({ @@ -666,11 +666,47 @@ class WalletOptionSelect extends Component { ); } + renderHistory = () => { + return ( + + + + {I18n.t('TRANSACTION_HISTORY')} + + + + { + this.props.loadingHistory ? + ( + + {Platform.OS === 'android' + ? + ( + <> + + {I18n.t('LOADING_DOTS')} + + + ) : + <> + + {I18n.t('LOADING_DOTS')} + + } + + ) : + this.renderHistoryTransactionList() + + } + + ); + } render() { !this.state.isDataHasLoaded && this.renderResultGetNanoCreditAccount(); return ( - + - + this._scrollView = component} > {this.state.displayModalHistory && this.renderModalHistoryDetail()} @@ -736,40 +772,15 @@ class WalletOptionSelect extends Component { )) } - - - {I18n.t('TRANSACTION_HISTORY')} - - - { - this.props.loadingHistory ? - ( - - {Platform.OS === 'android' - ? - ( - <> - - {I18n.t('LOADING_DOTS')} - - - ) : - <> - - {I18n.t('LOADING_DOTS')} - - } - - ) : - this.renderHistoryTransactionList() - + isEqual(this.props.navigation.state.params.optionSelect.type, 'NANO_CREDIT') ? + this.renderHistory() + : } - + - + ); } diff --git a/webservice/IlinkConstants.js b/webservice/IlinkConstants.js index ded419b8..36da1e14 100644 --- a/webservice/IlinkConstants.js +++ b/webservice/IlinkConstants.js @@ -67,6 +67,7 @@ export const saveOnesignalIds = testBaseUrl + '/notificationService/onesignal'; export const getNotificationUrl = testBaseUrl + '/notificationService/notifications'; export const getNanoCreditAccount = testBaseUrl + '/walletService/groups/nanoCredit/accounts'; export const getNanoCreditUserHistoryUrl = testBaseUrl + '/walletService/groups/nanoCredit/all_demands'; +export const getNanoCreditAgentHistoryUrl = testBaseUrl + '/walletService/groups/nanoCredit/guarantee_demands'; export const authKeyUrl = testBaseUrl + '/oauth/token'; export const videoUrl = "https://www.youtube.com/watch?v=wwGPDPsSLWY"; diff --git a/webservice/user/NanoCreditApi.js b/webservice/user/NanoCreditApi.js index 96c0f5c3..aa6933ea 100644 --- a/webservice/user/NanoCreditApi.js +++ b/webservice/user/NanoCreditApi.js @@ -3,7 +3,7 @@ import axios from "axios"; import I18n from 'react-native-i18n'; import { store } from "../../redux/store"; import { fetchCautionCreditDemandUserError, fetchCautionCreditDemandUserPending, fetchCautionCreditDemandUserReset, fetchCautionCreditDemandUserSuccess, fetchGetDemandsGroupError, fetchGetDemandsGroupPending, fetchGetDemandsGroupReset, fetchGetDemandsGroupSuccess, fetchGetUniqueDemandsGroupError, fetchGetUniqueDemandsGroupPending, fetchGetUniqueDemandsGroupReset, fetchGetUniqueDemandsGroupSuccess, fetchGetUserGroupDetailError, fetchGetUserGroupDetailPending, fetchGetUserGroupDetailReset, fetchGetUserGroupDetailSuccess, fetchEpargnerArgentUserPending, fetchEpargnerArgentUserSuccess, fetchEpargnerArgentUserError, fetchEpargnerArgentUserReset, fetchCasserEpargneUserPending, fetchCasserEpargneUserSuccess, fetchCasserEpargneUserError, fetchCasserEpargneUserReset, fetchGetNanoCreditUserAccountPending, fetchGetNanoCreditUserAccountSuccess, fetchGetNanoCreditUserAccountError, fetchGetNanoCreditUserAccountReset, fetchGetNanoCreditUserHistoryPending, fetchGetNanoCreditUserHistorySuccess, fetchGetNanoCreditUserHistoryError, fetchGetNanoCreditUserHistoryReset } from "../../redux/actions/NanoCreditAction"; -import { cautionCreditDemandtUrl, getCreditDemand, groupUrl, refundCreditDemandUrl, getNanoCreditUserHistoryUrl, epargnerArgentUrl, casserEpargneUrl, getNanoCreditAccount } from "../IlinkConstants"; +import { cautionCreditDemandtUrl, getCreditDemand, groupUrl, refundCreditDemandUrl, getNanoCreditUserHistoryUrl, epargnerArgentUrl, casserEpargneUrl, getNanoCreditAccount, getNanoCreditAgentHistoryUrl } from "../IlinkConstants"; export const getNanoCreditDemandsAction = (id) => { @@ -276,7 +276,7 @@ export const getNanoCreditAccountReset = () => { } -export const getNanoCreditUserHistoryAction = (idUser) => { +export const getNanoCreditUserHistoryAction = (idUser, isUser) => { const auth = store.getState().authKeyReducer; const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : ''; @@ -285,7 +285,7 @@ export const getNanoCreditUserHistoryAction = (idUser) => { dispatch(fetchGetNanoCreditUserHistoryPending()); axios({ - url: `${getNanoCreditUserHistoryUrl}/${idUser}`, + url: `${isUser ? getNanoCreditUserHistoryUrl : getNanoCreditAgentHistoryUrl}/${idUser}`, method: 'GET', headers: { 'Authorization': authKey,