const { connect } = require('react-redux'); const preact = require('preact'); const actions = require('../actions'); const testGame = require('./../test.game'); const testInstance = require('./../test.instance'); const addState = connect( function receiveState(state) { const { ws, account, instances, team, cryps, game, } = state; function sendInstanceState(instance) { return ws.sendInstanceState(instance.id); } return { account, instances, team, cryps, game, sendInstanceState, }; }, function receiveDispatch(dispatch) { function setTestGame(id) { return dispatch(actions.setGame(testGame(id))); } function setTestInstance(id) { return dispatch(actions.setInstance(testInstance(id))); } function navTo(place) { dispatch(actions.setGame(null)); dispatch(actions.setInstance(null)); return dispatch(actions.setNav(place)); } return { setTestGame, setTestInstance, navTo, }; } ); function Nav(args) { const { account, sendInstanceState, team, cryps, instances, game, navTo, setTestGame, setTestInstance, } = args; function joinInstance(i) { if (game) navTo(null); sendInstanceState(i); return true; } const joined = instances.map(i => ( )); const teamElements = team.map((c, i) => { if (c) { const cryp = cryps.find(f => f.id === c); return ; } return ; }); return ( ); } module.exports = addState(Nav);