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

const actions = require('./../actions');

const addState = connect(
    function receiveState(state) {
        const { showNav } = state;
        return { showNav };
    },
    function receiveDispatch(dispatch) {
        function navToTeam() {
            return dispatch(actions.setNav('team'));
        }

        function setShowNav(v) {
            return dispatch(actions.setShowNav(v));
        }

        return {
            navToTeam,
            setShowNav,
        };
    }
);

function ListFooter(args) {
    const {
        showNav,

        navToTeam,
        setShowNav,
    } = args;

    return (
        <footer>
            <button id="nav-btn" onClick={() => setShowNav(!showNav)} >☰</button>
            <button
                onClick={() => navToTeam()}>
                Back
            </button>
        </footer>
    );
}

module.exports = addState(ListFooter);
