const { connect } = require('preact-redux');

const CrypList = require('./cryp.list.component');
const actions = require('./../actions');

const addState = connect(
    function receiveState(state) {
        const { ws, cryps, selectedCryps } = state;
        return { cryps, selectedCryps };
    },

    function receiveDispatch(dispatch) {
        function setSelectedCryps(crypIds) {
            dispatch(actions.setSelectedCryps(crypIds));
        }
        return { setSelectedCryps };
    }
);

module.exports = addState(CrypList);
