// eslint-disable-next-line
const preact = require('preact');
const { connect } = require('preact-redux');

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

const TeamFooter = require('./team.footer');
const PlayFooter = require('./play.footer');
const InstanceFooter = require('./instance.footer');
const GameFooter = require('./game.footer');

const addState = connect(
    ({ nav, instance, game, account }) => {
        return { nav, instance, game, account };
    },
    dispatch => ({
        setShowNav: v => dispatch(actions.setShowNav(v)),
    })
);

function renderHeader(args) {
    const {
        nav,
        instance,
        game,
        account,
    } = args;

    if (!account) return false;
    if (game) return <GameFooter />;
    if (instance) return <InstanceFooter />;

    if (nav === 'team' || nav === 'account') return <TeamFooter />;
    if (nav === 'play' || nav === 'shop' || !nav) return <PlayFooter />;
}


module.exports = addState(renderHeader);
