WithdrawalRecordContainer.js 1.81 KB
'use strict';

import React, {Component} from 'react';

import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as allianceActions from '../reducers/alliance/allianceActions';
import WithdrawalRecord from "../components/WithdrawalRecord";
import LoadingIndicator from '../../common/components/LoadingIndicator';
import {StyleSheet, View} from "react-native";

const actions = [
    allianceActions,
];

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 WithdrawalRecordContainer extends Component {
    constructor(props) {
        super(props);
        this._onEndReached = this._onEndReached.bind(this);
    }

    componentDidMount() {
        this.props.actions.getSettlementRecord();
    }

    componentWillUnmount() {

    }

    _onEndReached() {
        this.props.actions.getSettlementRecord();
    }

    render() {
        let {settlementRecordList} = this.props.alliance;
        let isFetching = settlementRecordList.isFetching;
        return (
            <View style={styles.container}>
                <WithdrawalRecord
                    settlementRecordList={settlementRecordList}
                    onEndReached={this._onEndReached}/>
                <LoadingIndicator isVisible={isFetching}/>
            </View>
        )
    }
}

let styles = StyleSheet.create({
    container: {
        flex: 1,
    },
});

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