Historique demande cautionnnes agent ok

This commit is contained in:
Brice Zele 2020-10-04 16:31:16 +01:00
parent c6581c4b1d
commit e8c621331d
3 changed files with 153 additions and 141 deletions

View File

@ -61,7 +61,9 @@ class WalletOptionSelect extends Component {
if (user !== undefined) { if (user !== undefined) {
if (typeof user.category === 'undefined') { if (typeof user.category === 'undefined') {
this.props.getNanoCreditAccountAction(user.id); 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 }); this.setState({ user });
} }
@ -75,8 +77,12 @@ class WalletOptionSelect extends Component {
readUser().then((user) => { readUser().then((user) => {
if (user) { if (user) {
if (user !== undefined) { if (user !== undefined) {
this.props.getNanoCreditUserHistoryAction(user.id); if (typeof user.category === 'undefined') {
this.props.getNanoCreditAccountAction(user.id); 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 {
</View> </View>
<View style={{ flexDirection: 'row', marginTop: 30, marginBottom: 10, flex: 1, alignItems: 'center', justifyContent: 'center' }}> <View style={{ flexDirection: 'row', marginTop: 30, marginBottom: 10, flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Tag icon={<Icon name='update' size={20} color={Color.whiteColor} style={{ marginLeft: -15 }} />} <Tag icon={<Icon name='update' size={20} color={Color.whiteColor} style={{ marginLeft: -15 }} />}
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 primary
onPress={() => { onPress={() => {
this._scrollView.scrollToEnd();
}}>{I18n.t('SAVINGS')} }}>{I18n.t('HISTORY')}
</Tag>
<Tag icon={<Icon name='update' size={20} color={Color.whiteColor} />} primary
style={{ width: 110, borderTopLeftRadius: 0, borderBottomLeftRadius: 0, }}>
{I18n.t('CREDIT')}
</Tag> </Tag>
</View> </View>
@ -411,7 +413,7 @@ class WalletOptionSelect extends Component {
return ( return (
<TouchableOpacity onPress={() => { this.setState({ displayModalHistory: true, historyItemDetail: item }) }} style={[styles.contentService, { borderBottomColor: Color.primaryColor }]}> <TouchableOpacity onPress={() => { 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) => (
<View style={{ alignItems: 'center' }} key={i}> <View style={{ alignItems: 'center' }} key={i}>
<Text style={[Typography.overline, Color.grayColor], { marginTop: 4 }}> <Text style={[Typography.overline, Color.grayColor], { marginTop: 4 }}>
{ {
@ -440,9 +442,9 @@ class WalletOptionSelect extends Component {
<Dialog.Title>Détail de l'historique</Dialog.Title> <Dialog.Title>Détail de l'historique</Dialog.Title>
<ScrollView persistentScrollbar={true}> {
{ isEqual(historyItemDetail.type_historique, 'N') ?
isEqual(historyItemDetail.type_historique, 'N') ? <ScrollView persistentScrollbar={true}>
<View style={[styles.blockView, { borderBottomColor: Color.borderColor }]}> <View style={[styles.blockView, { borderBottomColor: Color.borderColor }]}>
<View style={{ flexDirection: 'row', marginTop: 10 }}> <View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
@ -557,102 +559,100 @@ class WalletOptionSelect extends Component {
</View> </View>
</View> </View>
</View> </View>
</ScrollView>
: :
<View style={[styles.blockView, { borderBottomColor: Color.borderColor }]}> <View style={[styles.blockView, { borderBottomColor: Color.borderColor }]}>
<View style={{ flexDirection: 'row', marginTop: 10 }}> <View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<Text style={[styles.body2]}>Type</Text> <Text style={[styles.body2]}>Type</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{displayTransactionType(this.state.historyItemDetail.type_historique)}</Text>
</View>
</View> </View>
<View style={{ flexDirection: 'row', marginTop: 10 }}> <View style={{ flex: 1, alignItems: 'flex-end' }}>
<View style={{ flex: 1 }}> <Text style={[Typography.caption1, Color.grayColor]}>{displayTransactionType(this.state.historyItemDetail.type_historique)}</Text>
<Text style={[styles.body2]}>{I18n.t('ID_DEMAND')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.id_demande}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>{I18n.t('STATUS')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.etat}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>{I18n.t('DEMAND_DURATION_IN_MONTH')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.duree_mois}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>Type</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.type}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('AMOUNT')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.montant + ' ' + this.state.wallet.currency_code}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('TAXES')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.taxe + ' ' + this.state.wallet.currency_code}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('INTERET')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.interet + ' ' + this.state.wallet.currency_code}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>{I18n.t('CREATION_DATE')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.date_creation}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('FINAL_DATE')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.date_fin}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('CASSATION_DATE')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.date_cassation}</Text>
</View>
</View> </View>
</View> </View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>{I18n.t('ID_DEMAND')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.id_demande}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>{I18n.t('STATUS')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.etat}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>{I18n.t('DEMAND_DURATION_IN_MONTH')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.duree_mois}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>Type</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.type}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('AMOUNT')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.montant + ' ' + this.state.wallet.currency_code}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('TAXES')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.taxe + ' ' + this.state.wallet.currency_code}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('INTERET')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.interet + ' ' + this.state.wallet.currency_code}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text style={[styles.body2]}>{I18n.t('CREATION_DATE')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.date_creation}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('FINAL_DATE')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.date_fin}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ flex: 1 }}>
<Text tyle={[Typography.body2]}>{I18n.t('CASSATION_DATE')}</Text>
</View>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={[Typography.caption1, Color.grayColor]}>{this.state.historyItemDetail.date_cassation}</Text>
</View>
</View>
</View>
}
}
</ScrollView>
<Dialog.Button bold={true} label={I18n.t('OK')} onPress={() => { <Dialog.Button bold={true} label={I18n.t('OK')} onPress={() => {
this.setState({ this.setState({
@ -666,11 +666,47 @@ class WalletOptionSelect extends Component {
); );
} }
renderHistory = () => {
return (
<View style={{ backgroundColor: Color.containerBackgroundColor, flex: 1 }}>
<View style={[styles.checkDefault, { borderBottomColor: Color.borderColor }]}>
<Text
style={[Typography.title3, Typography.semibold]}>
{I18n.t('TRANSACTION_HISTORY')}
</Text>
</View>
{
this.props.loadingHistory ?
(
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
{Platform.OS === 'android'
?
(
<>
<ProgressBarAndroid />
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
) :
<>
<ActivityIndicator size="large" color={'#ccc'} />
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
}
</View>
) :
this.renderHistoryTransactionList()
}
</View>
);
}
render() { render() {
!this.state.isDataHasLoaded && this.renderResultGetNanoCreditAccount(); !this.state.isDataHasLoaded && this.renderResultGetNanoCreditAccount();
return ( return (
<Provider> <Provider>
<ScrollView style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<StatusBar <StatusBar
backgroundColor={Color.primaryDarkColor} backgroundColor={Color.primaryDarkColor}
@ -688,7 +724,7 @@ class WalletOptionSelect extends Component {
/> />
</Appbar.Header> </Appbar.Header>
<View style={styles.container}> <ScrollView style={styles.container} ref={component => this._scrollView = component} >
{this.state.displayModalHistory && this.renderModalHistoryDetail()} {this.state.displayModalHistory && this.renderModalHistoryDetail()}
@ -736,40 +772,15 @@ class WalletOptionSelect extends Component {
)) ))
} }
<View style={[styles.checkDefault, { borderBottomColor: Color.borderColor }]}>
<Text
style={[Typography.title3, Typography.semibold]}>
{I18n.t('TRANSACTION_HISTORY')}
</Text>
</View>
{ {
this.props.loadingHistory ? isEqual(this.props.navigation.state.params.optionSelect.type, 'NANO_CREDIT') ?
( this.renderHistory()
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> : <View style={{ flex: 1 }} />
{Platform.OS === 'android'
?
(
<>
<ProgressBarAndroid />
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
) :
<>
<ActivityIndicator size="large" color={'#ccc'} />
<Text>{I18n.t('LOADING_DOTS')}</Text>
</>
}
</View>
) :
this.renderHistoryTransactionList()
} }
</View> </ScrollView>
</ScrollView> </View>
</Provider> </Provider>
); );
} }

View File

@ -67,6 +67,7 @@ export const saveOnesignalIds = testBaseUrl + '/notificationService/onesignal';
export const getNotificationUrl = testBaseUrl + '/notificationService/notifications'; export const getNotificationUrl = testBaseUrl + '/notificationService/notifications';
export const getNanoCreditAccount = testBaseUrl + '/walletService/groups/nanoCredit/accounts'; export const getNanoCreditAccount = testBaseUrl + '/walletService/groups/nanoCredit/accounts';
export const getNanoCreditUserHistoryUrl = testBaseUrl + '/walletService/groups/nanoCredit/all_demands'; 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 authKeyUrl = testBaseUrl + '/oauth/token';
export const videoUrl = "https://www.youtube.com/watch?v=wwGPDPsSLWY"; export const videoUrl = "https://www.youtube.com/watch?v=wwGPDPsSLWY";

View File

@ -3,7 +3,7 @@ import axios from "axios";
import I18n from 'react-native-i18n'; import I18n from 'react-native-i18n';
import { store } from "../../redux/store"; 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 { 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) => { 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 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}` : '';
@ -285,7 +285,7 @@ export const getNanoCreditUserHistoryAction = (idUser) => {
dispatch(fetchGetNanoCreditUserHistoryPending()); dispatch(fetchGetNanoCreditUserHistoryPending());
axios({ axios({
url: `${getNanoCreditUserHistoryUrl}/${idUser}`, url: `${isUser ? getNanoCreditUserHistoryUrl : getNanoCreditAgentHistoryUrl}/${idUser}`,
method: 'GET', method: 'GET',
headers: { headers: {
'Authorization': authKey, 'Authorization': authKey,