67 lines
1.7 KiB
JavaScript
67 lines
1.7 KiB
JavaScript
const preact = require('preact');
|
|
const { connect } = require('preact-redux');
|
|
|
|
const actions = require('./../actions');
|
|
|
|
const addState = connect(
|
|
function receiveState(state) {
|
|
const {
|
|
constructs,
|
|
teamPage,
|
|
teamSelect,
|
|
ws,
|
|
} = state;
|
|
|
|
function sendAccountSetTeam() {
|
|
return ws.sendAccountSetTeam(teamSelect);
|
|
}
|
|
|
|
return {
|
|
constructLength: constructs.length,
|
|
sendAccountSetTeam,
|
|
teamPage,
|
|
teamSelect,
|
|
};
|
|
},
|
|
|
|
function receiveDispatch(dispatch) {
|
|
function setTeamPage(value) {
|
|
return dispatch(actions.setTeamPage(value));
|
|
}
|
|
return {
|
|
setTeamPage,
|
|
};
|
|
}
|
|
);
|
|
|
|
function TeamCtrl(args) {
|
|
const {
|
|
constructLength,
|
|
sendAccountSetTeam,
|
|
setTeamPage,
|
|
teamPage,
|
|
teamSelect,
|
|
} = args;
|
|
|
|
const disableDecrement = teamPage === 0;
|
|
const disableIncrement = (teamPage + 1) * 6 >= constructLength;
|
|
return (
|
|
<aside>
|
|
<div class="timer-container"></div>
|
|
<button
|
|
class='ready'
|
|
disabled={teamSelect.some(c => !c)}
|
|
onClick={sendAccountSetTeam}>
|
|
Set
|
|
</button>
|
|
<div class="team-page-ctrl">
|
|
<button onClick={() => setTeamPage(teamPage - 1)} disabled={disableDecrement}> « </button>
|
|
<h2> {teamPage} </h2>
|
|
<button onClick={() => setTeamPage(teamPage + 1)} disabled={disableIncrement}> » </button>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|
|
|
|
module.exports = addState(TeamCtrl);
|