import React, {Component} from 'react';
import {
ActivityIndicator,
Image,
Platform,
ProgressBarAndroid,
ScrollView,
StatusBar,
StyleSheet,
Text,
TouchableOpacity,
View
} from 'react-native';
import I18n from 'react-native-i18n';
import {Appbar, Provider} from 'react-native-paper';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {Color} from '../../config/Color';
import {Typography} from '../../config/typography';
import * as Utils from '../../utils/DeviceUtils';
import {IlinkEmitter} from "../../utils/events";
import {connect} from "react-redux";
import {bindActionCreators} from "redux";
import {getBankListAction, getBankListReset} from "../../webservice/BankApi";
import {getOperatorListAction, getOperatorListReset} from "../../webservice/WalletApi";
import {store} from "../../redux/store";
const route = require('../../route.json');
let slugify = require('slugify');
class SouscrireAssuranceUser extends Component {
constructor(props) {
super(props);
IlinkEmitter.on("langueChange", this.updateLangue.bind(this));
this.state = {
options: this.props.navigation.state.params.optionSelect,
wallet: store.getState().walletDetailReducer.result.response
}
console.log("OPERATEUR OPTION PROPS", this.props);
console.log("OPERATEUR OPTION STATE", this.state);
}
updateLangue() {
this.props.navigation.setParams({name: I18n.t('WALLET')})
this.forceUpdate();
}
static navigationOptions = ({navigation}) => ({
header: null,
headerMode: 'none',
headerTitle: null,
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: {backgroundColor: '#694fad'},
drawerLabel: I18n.t('INSURANCE_LIST'),
drawerIcon: ({tintColor}) => (
)
});
redirectToRoute = (item) => {
/* console.log("Item selected", item);
if (this.state.options.length > 0) {
this.props.navigation.push(this.state.options[0].screen, {
title: item.operator_name,
type: this.state.options[0].type,
operator_id: item.id_operator,
typeOperator: this.state.operatorType
});
} else {
if (this.state.user.category === 'geolocated')
this.props.navigation.navigate(route.envoieWalletToBankAgent, {bank: item});
else
this.props.navigation.navigate(route.envoieWalletToBankUser, {bank: item});
}
*/
}
renderLoader = () => {
return (
{Platform.OS === 'android'
?
(
<>
{I18n.t('LOADING_DOTS')}
>
) :
<>
{I18n.t('LOADING_DOTS')}
>
}
)
}
renderItem = (item, index) => {
return (
{
this.redirectToRoute(item);
}}>
{item.title}
{I18n.t('AMOUNT')}: {`${item.amount}`}
)
}
renderBankList = () => {
const {result, error} = this.props;
const {options} = this.state;
return (
Array.isArray(options) && (options.length) > 0 ?
(
{
options.map((item, index) => (
this.renderItem(item, index)
))
}
) :
(
{I18n.t('NO_OPERATOR_AVAILABLE')}
)
)
}
renderItemElement = (item, index) => {
return (
{
this.props.navigation.navigate(item.screen, {
type: item.type,
title: item.title
})
}}>
{item.title}
{item.title}
)
}
renderList = () => {
const {options} = this.state;
return (
{
options.map((item, index) => (
this.renderItem(item, index)
))
}
);
}
render() {
console.log("OPERATEUR OPTION STATE", this.state.options.length);
return (
{
this.props.navigation.pop()
}}
/>
{
this.renderBankList()
}
);
}
}
const mapStateToProps = state => ({
loading: state.getListOperatorReducer.loading,
result: state.getListOperatorReducer.result,
error: state.getListOperatorReducer.error,
});
const mapDispatchToProps = dispatch => bindActionCreators({
getBankListAction,
getBankListReset,
getOperatorListAction,
getOperatorListReset,
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(SouscrireAssuranceUser);
const styles = StyleSheet.create({
container: {
flex: 1,
},
paymentItem: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
borderBottomWidth: 1,
paddingVertical: 5,
width: "100%",
marginBottom: 15
},
iconContent: {
width: 60,
marginRight: 10,
alignItems: "center"
},
item: {
paddingVertical: 15,
borderBottomWidth: 1,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
},
/* item: {
paddingVertical: 15,
borderBottomWidth: 1,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
}, */
lottie: {
width: 540,
height: 240
},
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(60),
paddingHorizontal: 10,
justifyContent: 'space-between',
alignItems: 'flex-start',
flex: 1,
},
contentTitle: {
paddingTop: 12,
}
});