2019-03-03 23:18:23 +02:00
|
|
|
import { connect } from 'react-redux';
|
2020-04-16 21:16:20 +03:00
|
|
|
import { debounce } from 'lodash';
|
|
|
|
|
2019-05-20 00:02:32 +03:00
|
|
|
import Poll from 'flavours/glitch/components/poll';
|
2020-04-17 22:54:25 +03:00
|
|
|
import { fetchPoll, vote } from 'flavours/glitch/actions/polls';
|
2020-04-16 21:16:20 +03:00
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch, { pollId }) => ({
|
|
|
|
refresh: debounce(
|
|
|
|
() => {
|
|
|
|
dispatch(fetchPoll(pollId));
|
|
|
|
},
|
|
|
|
1000,
|
|
|
|
{ leading: true },
|
|
|
|
),
|
2020-04-17 22:54:25 +03:00
|
|
|
|
|
|
|
onVote (choices) {
|
|
|
|
dispatch(vote(pollId, choices));
|
|
|
|
},
|
2020-04-16 21:16:20 +03:00
|
|
|
});
|
2019-03-03 23:18:23 +02:00
|
|
|
|
|
|
|
const mapStateToProps = (state, { pollId }) => ({
|
|
|
|
poll: state.getIn(['polls', pollId]),
|
|
|
|
});
|
|
|
|
|
2020-04-16 21:16:20 +03:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Poll);
|