import { connect } from 'react-redux';

import { setActiveEvent } from '../../actions/events.js';
import EventListItem from '../../components/Events/EventListItem.js';

const mapStateToProps = (state, ownProps) => {
    const { event } = ownProps;

    return {
        description: event.get('description'),
        endTime: event.get('endTime'),
        id: event.get('id'),
        images: event.get('images').toArray(),
        isTicketed: event.get('isTicketed'),
        postCount: event.get('posts').size,
        showFrom: event.get('showFrom'),
        showUntil: event.get('showUntil'),
        startTime: event.get('startTime'),
        tagline: event.get('tagline'),
        title: event.get('title'),
    };
};

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

export default connect(
    mapStateToProps,
    null,
)(AuctionListItem);
