import {Dispatch} from 'redux'
import {connect} from 'react-redux'
import {StateMap, countActions} from 'mastodon-data'
import App from '../components/App'

function mapStateToProps (state: StateMap) {
  return { count: state.getIn(['data', 'count', 'value']) }
}

function mapDispatchToProps (dispatch: Dispatch<void>) {
  return {
    onClickIncrement: () => { dispatch(countActions.increment()) },
    onClickDecrement: () => { dispatch(countActions.decrement()) }
  }
}

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(App) as React.ComponentClass<{}>
