import React, {Component} from 'react';
import {
ActivityIndicator, Alert, FlatList,
Platform,
ProgressBarAndroid,
ScrollView,
StatusBar,
StyleSheet,
Text,
TouchableOpacity,
View
} from 'react-native';
import {connectActionSheet} from '@expo/react-native-action-sheet'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import I18n from 'react-native-i18n';
import isEqual from 'lodash/isEqual';
import isNil from 'lodash/isNil';
import omit from 'lodash/omit';
import * as Utils from '../../utils/DeviceUtils';
import {Color} from '../../config/Color';
import {IlinkEmitter} from "../../utils/events";
import {Appbar, Provider} from 'react-native-paper';
import {readUser} from '../../webservice/AuthApi';
import {
getNanoCreditAccountAction,
getNanoCreditAccountReset,
getNanoCreditUserHistoryAction,
getNanoCreditUserHistoryReset
} from '../../webservice/user/NanoCreditApi';
import _ from 'lodash';
import Icons from 'react-native-vector-icons/Ionicons'
import {Typography} from '../../config/typography';
import LottieView from 'lottie-react-native';
import {
cutString,
cutStringWithoutDot,
displayToast,
displayTransactionType, nanoCreditHistoryLabel, nanoSanteHistoryLabel,
transactionHistoryIlinkLabel
} from '../../utils/UtilsFunction';
import chunk from 'lodash/chunk';
import thousands from 'thousands';
import Tag from '../../components/Tag';
import Dialog from "react-native-dialog";
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
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";
import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
import FontAwesome from "react-native-vector-icons/FontAwesome";
import {
fetchGetAmountConsultationReset, fetchGetConsultation,
fetchGetConsultationReset,
fetchGetDrugAppareilReset,
fetchGetNetworkActsReset,
fetchGetProviderClassReset,
fetchGetSubscriptionListReset,
fetchGetUserByIdQRCodeReset,
fetchGetUserByNameOrNumberReset
} from "../../redux/insurance/insurance.actions";
import {
facturerSoinAction,
facturerSoinReset,
getInvoiceHistoryAction,
getInvoiceHistoryReset, getSoinHistoryAction
} from "../../webservice/NanoCreditApi";
import {facturerSoinReducer} from "../../redux/insurance/insurance.reducer";
import SpinnerOverlay from "../../components/SpinnerOverlayComponent";
import AccordionComponent from "../../components/AccordionComponent";
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
import {pdfViewerUrl} from "../../webservice/IlinkConstants";
const route = require('./../../route.json');
let slugify = require('slugify');
class WalletOptionSelect extends Component {
constructor(props) {
super(props);
this.state = {
options: this.props.navigation.state.params.optionSelect.options,
title: this.props.navigation.state.params.optionSelect.title,
subTitle: this.props.navigation.state.params.optionSelect.subTitle,
type: this.props.navigation.state.params.optionSelect.type,
wallet: this.props.navigation.state.params.wallet,
lottie: this.props.navigation.state.params.lottie,
onGoBack: this.props.navigation.state.params.onGoBack,
isIdentified: store.getState().getUserIdentificationReducer.result !== null ? store.getState().getUserIdentificationReducer.result.response.isIdentified : false,
isNanoCredit: this.props.navigation.state.params.hasOwnProperty('isNanoCredit'),
isNanoSante: this.props.navigation.state.params.hasOwnProperty('isNanoSante'),
isNanoSanteAgent: this.props.navigation.state.params.hasOwnProperty('isNanoSanteAgent'),
user: null,
displayModalHistory: false,
historyItemDetail: null,
isDataHasLoaded: false,
historyResult: [],
page: 1,
loadMore: false,
historiqueDetailLabel: I18n.t('INVOICE')
}
console.log("WALLET OPTION PROPS", this.props);
console.log("WALLET OPTION STATE", this.state);
IlinkEmitter.on("langueChange", this.updateLangue.bind(this));
this.props.getNanoCreditAccountReset();
this.props.facturerSoinReset();
this.props.getNanoCreditUserHistoryReset();
this.props.getInvoiceHistoryReset();
readUser().then((user) => {
if (user) {
if (user !== undefined) {
if (user.category === undefined) {
this.props.getNanoCreditAccountAction(user.id);
this.props.getNanoCreditUserHistoryAction(user.id, true);
} else {
if (user.category === 'geolocated') {
this.props.getNanoCreditUserHistoryAction(this.state.wallet.id, false);
if(this.state.isNanoSanteAgent) {
this.props.getInvoiceHistoryAction(`?network_id=${user.network_id}&network_agent_id=${this.state.wallet.network_agent_id}&page=1&perPage=20`);
}
}
}
this.setState({user});
}
}
});
this.willFocus = this.props.navigation.addListener(
'willFocus',
payload => {
console.log("WIIL FOCUS CALL");
readUser().then((user) => {
if (user) {
if (user !== undefined) {
if (user.category === undefined) {
this.props.getNanoCreditAccountAction(user.id);
this.props.getNanoCreditUserHistoryAction(user.id, true);
//refresh wallet
this.props.getWalletDetailActivated(user.id, null);
this.props.getUserIdentificationAction(user.phone);
this.props.getWalletTransactionHistoryUser(user.id);
} else {
if (user.category === 'geolocated')
this.props.getNanoCreditUserHistoryAction(this.state.wallet.id, false);
}
}
}
this.props.fetchGetSubscriptionListReset();
this.props.fetchGetDrugAppareilReset();
this.props.fetchGetUserByNameOrNumberReset();
this.props.fetchGetUserByIdQRCodeReset();
this.props.fetchGetProviderClassReset();
this.props.fetchGetConsultationReset();
this.props.fetchGetNetworkActsReset();
this.props.facturerSoinReset();
});
});
}
static navigationOptions = ({navigation}) => ({
header: null,
headerMode: 'none',
headerTitle: null,
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: {backgroundColor: '#694fad'},
drawerLabel: I18n.t('CREDIT_MANAGE'),
drawerIcon: ({tintColor}) => (
)
});
renderResultGetNanoCreditAccount() {
const {result} = this.props;
console.log("BEFORE", this.props);
if (result !== null) {
if (result.response !== null) {
this.setState({
balance_credit: result.response.balance_credit,
balance_epargne: result.response.balance_epargne,
user: {
...this.state.user,
balance_credit: result.response.balance_credit,
balance_epargne: result.response.balance_epargne
},
isDataHasLoaded: true
});
console.log("AFTER", this.props);
}
}
}
componentDidMount() {
const {resultInsuranceHistory, errorInsuranceHistory} = this.props;
if (errorInsuranceHistory !== null) {
if (typeof errorInsuranceHistory.data !== 'undefined') {
Alert.alert(
I18n.t("ERROR_LABEL"),
errorInsuranceHistory.data.error,
[
{
text: I18n.t("OK"), onPress: () => {
this.props.getInvoiceHistoryReset();
}
}
],
{cancelable: false}
)
}
}
if (resultInsuranceHistory !== null) {
if (resultInsuranceHistory.response !== null) {
if(this.state.page < resultInsuranceHistory.response.last_page) {
this.setState({
historyResult: this.state.historyResult.concat(resultInsuranceHistory.response.data)
});
}
if(this.state.page === resultInsuranceHistory.response.last_page) {
this.setState({
page: this.state.page + 1,
historyResult: this.state.historyResult.concat(resultInsuranceHistory.response.data)
})
}
}
}
}
updateLangue() {
this.props.navigation.setParams({name: I18n.t('WALLET')});
this.forceUpdate()
}
redirectToRoute = (optionsParam) => {
console.warn("Wallet Select Props", optionsParam);
if (optionsParam.hasOwnProperty('hasSubMenu')) {
let options = [];
for (let index = 0; index < optionsParam.subMenuOption.length; index++) {
options.push(optionsParam.subMenuOption[index].title);
}
const destructiveButtonIndex = 0;
const cancelButtonIndex = 2;
this.props.showActionSheetWithOptions(
{
options,
cancelButtonIndex,
destructiveButtonIndex,
},
buttonIndex => {
this.props.navigation.push(optionsParam.subMenuOption[buttonIndex].screen);
},
);
} else {
switch (this.state.type) {
case 'FACTURE':
this.props.navigation.push(optionsParam.screen, {
optionSelect: optionsParam.subScreenOption,
onGoBack: () => this.props.navigation.state.params.onGoBack(),
});
break;
case 'DEPOT':
this.props.navigation.push(optionsParam.screen, {
optionSelect: optionsParam.subScreenOption,
wallet: this.state.wallet,
onGoBack: () => this.props.navigation.state.params.onGoBack(),
});
break;
case 'DEPOT_USER':
this.props.navigation.push(optionsParam.screen, {
wallet: this.state.wallet,
onGoBack: () => this.props.navigation.state.params.onGoBack(),
optionSelect: optionsParam.subScreenOption,
});
break;
case 'RETRAIT':
this.props.navigation.push(optionsParam.screen, {
wallet: this.state.wallet,
onGoBack: () => this.props.navigation.state.params.onGoBack(),
});
break;
case 'WALLET_TO_BANK':
this.props.navigation.push(optionsParam.screen, {
wallet: this.state.wallet,
optionSelect: optionsParam.subScreenOption,
onGoBack: () => this.props.navigation.state.params.onGoBack(),
});
break;
case 'NANO_CREDIT':
this.props.navigation.push(optionsParam.screen, {
wallet: this.state.wallet,
optionSelect: optionsParam.subScreenOption,
onGoBack: () => this.props.navigation.state.params.onGoBack(),
});
break;
case 'NANO_SANTE':
this.props.navigation.push(optionsParam.screen, {
wallet: this.state.wallet,
optionSelect: optionsParam.subScreenOption,
onGoBack: () => this.props.navigation.state.params.onGoBack(),
});
break;
default:
this.props.navigation.push(optionsParam.screen);
break;
}
}
}
renderItem = (options, isOneElement, index) => {
console.log("OPTIONS", options);
return (
isOneElement ?
<>
{
this.redirectToRoute(options);
}}
activeOpacity={0.9}>
{
options.hasOwnProperty('iconType') ?
:
}
20 ? 0 : 5}}>
{I18n.t(options.title)}
> :
<>
{
if (!_.isNil(this.state.isIdentified)) {
console.log(options);
if (_.isEqual(options.screen, 'createIdentificationUser')) {
if (this.state.isIdentified)
displayToast(I18n.t('ALREADY_IDENTIFIED'));
else
this.redirectToRoute(options);
} else if (_.isEqual(options.screen, 'modifyIdentificationUser')) {
if (!this.state.isIdentified)
displayToast(I18n.t('NOT_YET_IDENTIFY'));
else
this.redirectToRoute(options);
} else
this.redirectToRoute(options);
} else
this.redirectToRoute(options);
}}
activeOpacity={0.9}>
{
options.hasOwnProperty('iconType') ?
:
}
20 ? 0 : 5}}>
{I18n.t(options.title)}
>
)
};
updateLangue() {
this.props.navigation.setParams({name: I18n.t('WALLET')})
this.forceUpdate();
}
renderAccountDetail = (options) => (
<>
{I18n.t('CREDIT_ACCOUNT')}
{this.state.user !== null ?
{this.props.result != null ? `${thousands(this.props.result.response.balance_credit, ' ')} ${this.state.wallet.currency_code}` : `${thousands(this.state.user.balance_credit, ' ')} ${this.state.wallet.currency_code}`}
: null}
{I18n.t('SAVINGS_ACCOUNT')}
{this.state.user !== null ?
{this.props.result != null ? `${thousands(this.props.result.response.balance_epargne, ' ')} ${this.state.wallet.currency_code}` : `${thousands(this.state.user.balance_epargne, ' ')} ${this.state.wallet.currency_code}`}
: null}
}
style={{paddingRight: 10, width: 120, borderRightWidth: 1, borderRightColor: Color.whiteColor}}
primary
onPress={() => {
this._scrollView.scrollToEnd();
}}>{I18n.t('HISTORY')}
>
);
renderNanoSanteAccountDetail = (options) => (
<>
{/*
{I18n.t('CREDIT_ACCOUNT')}
{this.state.user !== null ?
{this.props.result != null ? `${thousands(this.props.result.response.balance_credit, ' ')} ${this.state.wallet.currency_code}` : `${thousands(this.state.user.balance_credit, ' ')} ${this.state.wallet.currency_code}`}
: null}
{I18n.t('SAVINGS_ACCOUNT')}
{this.state.user !== null ?
{this.props.result != null ? `${thousands(this.props.result.response.balance_epargne, ' ')} ${this.state.wallet.currency_code}` : `${thousands(this.state.user.balance_epargne, ' ')} ${this.state.wallet.currency_code}`}
: null}
}
style={{paddingRight: 10, width: 120, borderRightWidth: 1, borderRightColor: Color.whiteColor}}
primary
onPress={() => {
//this._scrollView.scrollToEnd();
}}>{I18n.t('ATTACH_ASSURANCE_CARD')}
*/}
>
);
renderNanoSanteAgentAccountDetail = (options) => (
<>
{/*
{I18n.t('CREDIT_ACCOUNT')}
{this.state.user !== null ?
{this.props.result != null ? `${thousands(this.props.result.response.balance_credit, ' ')} ${this.state.wallet.currency_code}` : `${thousands(this.state.user.balance_credit, ' ')} ${this.state.wallet.currency_code}`}
: null}
{I18n.t('SAVINGS_ACCOUNT')}
{this.state.user !== null ?
{this.props.result != null ? `${thousands(this.props.result.response.balance_epargne, ' ')} ${this.state.wallet.currency_code}` : `${thousands(this.state.user.balance_epargne, ' ')} ${this.state.wallet.currency_code}`}
: null}
*/}
}
style={{
paddingRight: 10,
width: "70%",
borderRightWidth: 1,
borderRightColor: Color.whiteColor
}}
primary
onPress={() => {
this.props.facturerSoinAction(`?network_agent_id=${this.state.wallet.network_agent_id}`);
//this._scrollView.scrollToEnd();
}}>{' ' + I18n.t('FACTURER_FEUILLES_SOINS')}
>
);
renderHistoryTransactionList = () => {
const {resultHistory, errorHistory} = this.props;
if (errorHistory !== null) {
if (typeof errorHistory.data !== 'undefined') {
return (
{errorHistory.data.error}
)
} else {
return (
{errorHistory}
)
}
}
if (resultHistory !== null) {
if (resultHistory.response !== null) {
return (
Array.isArray(resultHistory.response) && (resultHistory.response.length) > 0 ?
(
<>
{
transactionHistoryIlinkLabel().map((item, index) => (
{I18n.t(item.label)}
))
}
{
resultHistory.response.map((item, index) => (
this.renderHistoryTransactionItem(item, index)
))
}
>
) :
(
{I18n.t('NO_WALLET_HISTORY')}
)
)
}
}
}
renderHistoryTransactionItem = (item, index) => {
return (
{
this.setState({displayModalHistory: true, historyItemDetail: item})
}} style={[styles.contentService, {borderBottomColor: Color.primaryColor}]}>
{
!isNil(this.state.user.category) ?
Object.keys(omit(item, ['id', 'retrait_cash', 'montant_retire', 'type_historique', 'type_caution', 'id_demande', 'montant_rembourse', 'partiellement_rembourse', 'duree_mois', 'etat', 'interet', 'taxe', 'date_validation', 'date_remboursement_prevu', 'date_remboursement', 'id_user', 'id_wallet_agent', 'id_network', 'user', 'user_phone', 'agent', 'codeParrain'])).map((element, i) => (
{
isEqual(element, 'montant') ?
` ${item[element].length > 8 ? cutString(thousands(item[element], ' '), 6) : thousands(item[element], ' ')} ${this.state.wallet.currency_code}`
: isEqual(element, 'date_creation') ?
cutStringWithoutDot(item[element], 16)
: item[element]
}
))
:
Object.keys(omit(item, ['id', 'type', 'montant_retire', 'id_epargne', 'type_historique', 'date_demande', 'date_fin', 'date_remboursement_prevu', 'date_validation', 'date_cassation', 'date_remboursement', '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) => (
{
isEqual(element, 'montant') ?
` ${item[element].length > 8 ? cutString(thousands(item[element], ' '), 6) : thousands(item[element], ' ')} ${this.state.wallet.currency_code}`
: isEqual(element, 'date_creation') ?
cutStringWithoutDot(item[element], 16)
: item[element]
}
))
}
);
}
renderNanoSanteHistoryItem = (item, index) => {
return (
{
this.setState({displayModalHistory: true, historyItemDetail: item})
}} style={[styles.contentService, {borderBottomColor: Color.primaryColor}]}>
{
Object.keys(omit(item, ['created_at', 'currency_code', 'file_url', 'health_care_sheets', 'institution_code', 'institutation_name', 'insured_amount', 'insurer_amount', 'invoice_id',
'network_agent_id', 'network_id', 'period_end_at','period_start_at','updated_at'])).map((element, i) => (
{item[element]}
))
}
);
}
handleLoadMore = () => {
this.props.getInvoiceHistoryReset();
this.props.getInvoiceHistoryAction(`?network_id=${user.network_id}&insured_id=${user.agentId}&page=${this.state.page + 1}&perPage=20`);
this.setState({
page: this.state.page + 1
});
}
renderFooterLoader = () => {
return (
{Platform.OS === 'android'
?
(
<>
{I18n.t('LOADING_DOTS')}
>
) :
<>
{I18n.t('LOADING_DOTS')}
>
}
);
};
renderNanoSanteHistoryList = () => {
const {loadingInsuranceHistory, errorInsuranceHistory, resultInsuranceHistory} = this.props;
return (
<>
{`${I18n.t('HISTORY')} ${this.state.historiqueDetailLabel}`}
}
style={{
paddingRight: 10,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
borderRightWidth: 1,
borderRightColor: Color.whiteColor
}}
onPress={() => {
this.setState({historiqueDetailLabel: I18n.t('INVOICE')});
readUser().then((user) => {
if (user) {
if (user !== undefined) {
if (user.category === 'geolocated')
this.props.getInvoiceHistoryAction(`?network_id=${user.network_id}&network_agent_id=${this.state.wallet.network_agent_id}&page=1&perPage=20`);
}
}
});
}}/>
}
style={{ borderTopLeftRadius: 0, borderBottomLeftRadius: 0,}}
primary
onPress={() => {
this.setState({historiqueDetailLabel: I18n.t('SOINS')});
this.props.getSoinHistoryAction(this.state.wallet.network_agent_id, 'ALL', '', '&pagination=true&page=1');
}}/>
{
loadingInsuranceHistory ?
this.renderLoader() :
(<>
{
nanoSanteHistoryLabel().map((item, index) => (
{I18n.t(item.label)}
))
}
{
return (
{I18n.t('NO_WALLET_HISTORY')}
)
}}
data={this.state.historyResult}
keyExtractor={(item, index) => item.id}
renderItem={({item, index}) => (
this.renderNanoSanteHistoryItem(item)
)}
onEndReached={() => {
if (resultInsuranceHistory !== null) {
if (this.state.page < resultInsuranceHistory.response.last_page) {
this.setState({loadMore: true});
this.handleLoadMore();
}
}
}}
onEndReachedThreshold={0.5}
ListFooterComponent={resultInsuranceHistory !== null ? this.state.page < resultInsuranceHistory.response.last_page ? this.renderFooterLoader() : null : null}
/>
>
)
}
>
);
}
renderModalHistoryDetail = () => {
const {historyItemDetail} = this.state;
return (
{I18n.t('HISTORY_DETAIL')}
{
isNil(this.state.user.category) ?
isEqual(historyItemDetail.type_historique, 'N') ?
Type
{I18n.t(displayTransactionType(this.state.historyItemDetail.type_historique))}
{I18n.t('CAUTION_TYPE')}
{this.state.historyItemDetail.type_caution}
{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}
{I18n.t('AMOUNT')}
{this.state.historyItemDetail.montant + ' ' + this.state.wallet.currency_code}
{I18n.t('AMOUNT_REFUND')}
{this.state.historyItemDetail.montant_rembourse + ' ' + this.state.wallet.currency_code}
{I18n.t('AMOUNT_PARTIALLY_REFUND')}
{this.state.historyItemDetail.partiellement_rembourse + ' ' + 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('WITHDRAWAL_IN_CASH')}
{this.state.historyItemDetail.retrait_cash == 1 ? I18n.t('YES') : I18n.t('NO')}
{I18n.t('CREATION_DATE')}
{this.state.historyItemDetail.date_creation}
{I18n.t('VALIDATION_DATE')}
{this.state.historyItemDetail.date_validation}
{I18n.t('DATE_REMBOURSEMENT_PREVU')}
{this.state.historyItemDetail.date_remboursement_prevu}
{I18n.t('DATE_REMBOURSEMENT')}
{this.state.historyItemDetail.date_remboursement}
:
Type
{I18n.t(displayTransactionType(this.state.historyItemDetail.type_historique))}
{I18n.t('ID_SAVINGS')}
{this.state.historyItemDetail.id_epargne}
{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('AMOUNT_WITHDRAWAL')}
{this.state.historyItemDetail.montant_retire + ' ' + 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')}
{isEqual(this.state.historyItemDetail.type, 'SIMPLE') ? I18n.t('NON_APPLICABLE') : this.state.historyItemDetail.date_fin}
{I18n.t('CASSATION_DATE')}
{this.state.historyItemDetail.date_cassation}
: historyItemDetail.hasOwnProperty('insured_amount') ?
{I18n.t('INVOICE')}
{
this.setState({
displayModalHistory: !this.state.displayModalHistory,
});
navigation.push('PDFViewerScreen', {url: `${historyItemDetail.file_url}`, title: ''});
}}>
Facture.PDF
{I18n.t('INVOICE_ID')}
{this.state.historyItemDetail.invoice_id}
Date
{this.state.historyItemDetail.created_at}
{I18n.t('AMOUNT')}
{this.state.historyItemDetail.amount}
{I18n.t('MONTANT_ASSURANCE')}
{this.state.historyItemDetail.insured_amount}
{I18n.t('MONTANT_ASSURE')}
{this.state.historyItemDetail.insurer_amount}
{I18n.t('INSTITUTE_NAME')}
{this.state.historyItemDetail.institution_name}
{
this.state.historyItemDetail.health_care_sheets.map((history_care) => (
))
}
:
Type
{I18n.t(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}
{I18n.t('AMOUNT')}
{this.state.historyItemDetail.montant + ' ' + this.state.wallet.currency_code}
{I18n.t('AMOUNT_REFUND')}
{this.state.historyItemDetail.montant_rembourse + ' ' + this.state.wallet.currency_code}
{I18n.t('AMOUNT_PARTIALLY_REFUND')}
{this.state.historyItemDetail.partiellement_rembourse + ' ' + 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('WITHDRAWAL_IN_CASH')}
{this.state.historyItemDetail.retrait_cash == 1 ? I18n.t('YES') : I18n.t('NO')}
{I18n.t('CREATION_DATE')}
{this.state.historyItemDetail.date_creation}
{I18n.t('VALIDATION_DATE')}
{this.state.historyItemDetail.date_validation}
{I18n.t('DATE_REMBOURSEMENT_PREVU')}
{this.state.historyItemDetail.date_remboursement_prevu}
{I18n.t('DATE_REMBOURSEMENT')}
{this.state.historyItemDetail.date_remboursement}
}
{
this.setState({
displayModalHistory: !this.state.displayModalHistory,
});
}}/>
);
}
renderHistory = () => {
return (
{I18n.t('TRANSACTION_HISTORY')}
}
style={{
paddingRight: 10,
width: 120,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
borderRightWidth: 1,
borderRightColor: Color.whiteColor
}}
onPress={() => {
}}>
{` ${I18n.t('SOINS')}`}
}
style={{width: 110, borderTopLeftRadius: 0, borderBottomLeftRadius: 0,}}
primary
onPress={() => {
}}>
{` ${I18n.t('SOUSCRIPTION')}`}
{
this.props.loadingHistory ?
(
{Platform.OS === 'android'
?
(
<>
{I18n.t('LOADING_DOTS')}
>
) :
<>
{I18n.t('LOADING_DOTS')}
>
}
) : !isNil(this.state.user) &&
this.renderHistoryTransactionList()
}
);
}
renderLoader = () => {
return (
{Platform.OS === 'android'
?
(
<>
{I18n.t('LOADING_DOTS')}
>
) :
<>
{I18n.t('LOADING_DOTS')}
>
}
)
}
renderDialogFacturerSoin = () => {
const {resultFacturerSoin, errorFacturerSoin} = this.props;
if (errorFacturerSoin !== null) {
if (typeof errorFacturerSoin.data !== 'undefined') {
Alert.alert(
I18n.t("INFORMATION_MESSAGE"),
errorFacturerSoin.data.error,
[
{
text: I18n.t("OK"), onPress: () => {
this.props.facturerSoinReset();
}
}
],
{cancelable: false}
)
}
}
if (resultFacturerSoin !== null) {
if (resultFacturerSoin.response !== null) {
Alert.alert(
I18n.t("SUCCESS"),
resultFacturerSoin.response,
[
{
text: I18n.t("OK"), onPress: () => {
this.props.facturerSoinReset();
}
}
],
{cancelable: false}
)
}
}
}
render() {
!this.state.isDataHasLoaded && this.renderResultGetNanoCreditAccount();
return (
{(this.props.resultFacturerSoin !== null || this.props.errorFacturerSoin !== null) && this.renderDialogFacturerSoin()}
{
this.props.navigation.pop()
}}
/>
this._scrollView = component}>
{this.state.displayModalHistory && this.renderModalHistoryDetail()}
{
this.state.isNanoCredit ?
this.renderAccountDetail()
: this.state.isNanoSante ?
this.renderNanoSanteAccountDetail() :
this.state.isNanoSanteAgent ?
this.renderNanoSanteAgentAccountDetail() :
}
{
this.state.isNanoSante ?
this.state.options.map((item) => (
<>
{I18n.t(item.title)}
{
chunk(item.options, 2).map((item, index) => (
{
item.length === 1 ?
item.map((wallet, i) => (
this.renderItem(wallet, true, i)
)) :
item.map((wallet, i) => (
this.renderItem(wallet, false, i)
))
}
))
}
>
)) :
(<>
{I18n.t('OPERATIONS')}
{
chunk(this.state.options, 2).map((item, index) => (
{
item.length === 1 ?
item.map((wallet, i) => (
this.renderItem(wallet, true, i)
)) :
item.map((wallet, i) => (
this.renderItem(wallet, false, i)
))
}
))
}
>)
}
{/*this.state.isNanoSanteAgent && this.renderNanoSanteHistoryList()*/}
{/* {
isEqual(this.props.navigation.state.params.optionSelect.type, 'NANO_CREDIT')
|| isEqual(this.props.navigation.state.params.optionSelect.type, 'NANO_SANTE') ?
this.renderHistory()
:
}*/}
);
}
}
const mapStateToProps = state => ({
loading: state.getNanoCreditAccountUserReducer.loading,
result: state.getNanoCreditAccountUserReducer.result,
error: state.getNanoCreditAccountUserReducer.error,
loadingHistory: state.getNanoCreditHistoryUserReducer.loading,
resultHistory: state.getNanoCreditHistoryUserReducer.result,
errorHistory: state.getNanoCreditHistoryUserReducer.error,
loadingFacturerSoin: state.facturerSoinReducer.loading,
resultFacturerSoin: state.facturerSoinReducer.result,
errorFacturerSoin: state.facturerSoinReducer.error,
loadingInsuranceHistory: state.insuranceHistoryReducer.loading,
resultInsuranceHistory: state.insuranceHistoryReducer.result,
errorInsuranceHistory: state.insuranceHistoryReducer.error,
});
const mapDispatchToProps = dispatch => bindActionCreators({
getNanoCreditAccountAction,
getNanoCreditAccountReset,
getNanoCreditUserHistoryAction,
getNanoCreditUserHistoryReset,
fetchGetSubscriptionListReset,
fetchGetDrugAppareilReset,
fetchGetUserByNameOrNumberReset,
fetchGetUserByIdQRCodeReset,
fetchGetProviderClassReset,
fetchGetConsultationReset,
fetchGetNetworkActsReset,
facturerSoinReset,
facturerSoinAction,
getInvoiceHistoryAction,
getInvoiceHistoryReset,
getSoinHistoryAction,
getWalletDetailActivated,
getUserIdentificationAction,
getWalletTransactionHistoryUser
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(connectActionSheet(WalletOptionSelect));
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Color.containerBackgroundColor,
paddingHorizontal: 20,
},
item: {
paddingVertical: 15,
borderBottomWidth: 1,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
},
lottie: {
width: 540,
height: 240
},
circlePoint: {
width: 50,
height: 50,
borderRadius: 25,
marginRight: 5,
alignItems: 'center',
justifyContent: 'center',
},
checkDefault: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
borderBottomWidth: 1,
paddingVertical: 10,
marginTop: 5
},
transactionContainer: {
flexDirection: 'row',
paddingTop: 10,
},
containerTouch: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
shadowColor: Color.borderColor,
borderColor: Color.borderColor,
borderWidth: 0.5,
shadowOffset: {width: 1.5, height: 1.5},
shadowOpacity: 1.0,
elevation: 5,
borderRadius: 10,
backgroundColor: Color.cardBackgroundColor
},
contain: {
flexDirection: 'row',
justifyContent: 'space-between',
},
imageBanner: {
marginTop: 15,
marginLeft: 5,
width: Utils.scaleWithPixel(30),
height: Utils.scaleWithPixel(30)
},
content: {
height: Utils.scaleWithPixel(65),
paddingHorizontal: 10,
justifyContent: 'space-between',
alignItems: 'flex-start',
flex: 1,
},
contentTitle: {
paddingTop: 12,
},
contentService: {
paddingVertical: 10,
borderBottomWidth: 0.5,
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
},
blockView: {
paddingVertical: 10,
borderBottomWidth: 0.5,
},
containField: {
padding: 10,
marginBottom: 20,
borderWidth: 0.5,
shadowOffset: {width: 1.5, height: 1.5},
shadowOpacity: 1.0,
elevation: 5,
flexDirection: "row",
height: 140,
borderRadius: 10
},
paymentItem: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
borderBottomWidth: 1,
paddingVertical: 5,
width: responsiveWidth(100),
marginBottom: 15
},
iconContent: {
width: 60,
marginRight: 10,
alignItems: "center"
},
contentLeftItem: {
flex: 1,
paddingTop: 40,
paddingLeft: 10,
paddingRight: 10,
alignItems: "center"
},
tagFollow: {width: 150, margin: 10},
});