InstallmentMyCardContainer.js 2.21 KB
'use strict'

import React, {Component} from 'react';
import {
    StyleSheet,
    Dimensions,
    Platform,
    View,
    NativeModules,
    InteractionManager,
    NativeAppEventEmitter,
    Text,
} from 'react-native'

import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as installmentActions from '../reducers/installment/installmentActions';
import InstallmentStatus from '../components/installment/InstallmentStatus';
import ServerError from '../components/installment/ServerError';

const actions = [
    installmentActions,
];
function mapStateToProps(state) {
    return {
        ...state
    };
}
function mapDispatchToProps(dispatch) {

    const creators = Map()
        .merge(...actions)
        .filter(value => typeof value === 'function')
        .toObject();

    return {
        actions: bindActionCreators(creators, dispatch),
        dispatch
    };
}
class InstallmentMyCardContainer extends Component {
    constructor(props) {
        super(props);
        this._onPressStatusPageBtn = this._onPressStatusPageBtn.bind(this);
        this._reloadPage = this._reloadPage.bind(this);
    }
    componentDidMount() {
    }

    _reloadPage() {
        let {installmentStausPageInfo} = this.props.installment;
        let {originalParams} = installmentStausPageInfo;
        this.props.actions.setError(null);
        this.props.actions.setInstallmentStausPageParams(originalParams.statusCode, originalParams.failReason, originalParams.uid);
    }

    _onPressStatusPageBtn() {
        this.props.actions.onPressStatusPageBtn();
    }

    render() {
        let {installmentStausPageInfo,error} = this.props.installment;
        if (error) {
            return (
                <ServerError
                    reloadPage={this._reloadPage}
                />
            );
        }
        return (
            <InstallmentStatus
                installmentStausPageInfo={installmentStausPageInfo}
                onPressStatusPageBtn={this._onPressStatusPageBtn}
            />
        );
    }
}
let styles = StyleSheet.create({
    container: {
        flex: 1,
    },

});

export default connect(mapStateToProps, mapDispatchToProps)(InstallmentMyCardContainer);