import React from 'react' import Admin from './../admin' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import PlanIndexItem from './plan-index-item' import { fetchEntities } from '../actions/index' interface PlansIndexProps { fetchEntities: any; plans: any[]; tooltips: any[]; } interface PlansIndexState extends ComponentState { plans: any[]; tooltips: any[]; } class PlansIndex extends React.Component { constructor(props) { super(props); this.state = { fetching: true, plans: [], tooltips: [] }; } componentDidMount() { this.props.fetchEntities('plans').then(() => { this.setState({ fetching: false, plans: this.props.plans, tooltips: this.props.tooltips }); }); } render() { return(

Plans

{ Admin.renderSpinner(this.state.fetching) } { Admin.renderGrayedOut(this.state.fetching) } { this.state.plans.map((plan, index) => { return( ); }, this) }
); } componentDidUpdate() { Admin.matchColumnHeight(); } } const mapStateToProps = (reducers) => { return { plans: reducers.standardReducer.plans, tooltips: reducers.standardReducer.tooltips }; }; function mapDispatchToProps(dispatch) { return bindActionCreators({ fetchEntities }, dispatch); } export default connect(mapStateToProps, mapDispatchToProps)(PlansIndex);