import { connect } from 'react-redux';

import { fetchEvents } from '../actions/events.js';
import { getEventsAsList } from '../selectors/events.js';

import Events from '../screens/Events.js';

const matchStateToProps = (state) => {
    const events = getEventsAsList(state);
    console.log('events:', events);

    return { events };
};

const mapDispatchToProps = (dispatch) => ({
    fetchEvents: () => dispatch(fetchEvents(dispatch)),
});

export default connect(
    matchStateToProps,
    mapDispatchToProps,
)(Events);
