import { connect } from 'react-redux';

import { fetchItems } from '../actions/items.js';
import { fetchAuctionStatus } from '../actions/auctionStatus.js';

import { getAuctionItemsAsList } from '../selectors/items.js';

import Auction from './Auction.js';

const matchStateToProps = (state) => {
    const items = getAuctionItemsAsList(state);
    console.log('items:', items);

    return { items };
};

const mapDispatchToProps = (dispatch) => ({
    changeViewMode: (mode) => dispatch(changeViewMode(mode)),
    fetchItems: () => dispatch(fetchItems(dispatch)),
    fetchStatus: () => dispatch(fetchAuctionStatus(dispatch)),
});

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