account apply

This commit is contained in:
ntr
2019-09-22 18:36:03 +10:00
parent 8151c37f96
commit c4a291e890
5 changed files with 69 additions and 2 deletions
+24 -2
View File
@@ -4,11 +4,20 @@ const { connect } = require('preact-redux');
const addState = connect(
function receiveState(state) {
const {
ws,
account,
mtxActive,
} = state;
function sendMtxAccountApply() {
return ws.sendMtxAccountApply(mtxActive);
}
return {
account,
mtxActive,
sendMtxAccountApply,
};
}
);
@@ -17,10 +26,13 @@ const addState = connect(
function AccountBox(args) {
const {
account,
mtxActive,
sendMtxAccountApply,
} = args;
const imgStyle = account.img
? { 'background-image': `url(/imgs/${account.img}.svg)` }
? { 'background-image': `url(/imgs/${account.img}.svg)`, cursor: mtxActive ? 'pointer' : '' }
: null;
// if (!isTop) {
@@ -33,10 +45,20 @@ function AccountBox(args) {
// );
// }
const onClick = () => {
if (!mtxActive) return false;
return sendMtxAccountApply();
};
return (
<div class='player-box bottom'>
<div class="msg">&nbsp;</div>
<div class="img avatar" id={account.img} style={imgStyle}></div>
<div
class="img avatar"
id={account.img}
onClick={onClick}
style={imgStyle}>
</div>
<div class="name">{account.name}</div>
<div class="score">0 MMR</div>
</div>
+5
View File
@@ -150,6 +150,10 @@ function createSocket(events) {
}
}
function sendMtxAccountApply(mtx) {
send(['MtxAccountApply', { mtx }]);
}
function sendMtxBuy(mtx) {
send(['MtxBuy', { mtx }]);
}
@@ -368,6 +372,7 @@ function createSocket(events) {
sendSubscriptionState,
sendSubscriptionEnding,
sendMtxAccountApply,
sendMtxApply,
sendMtxBuy,
sendMtxConstructSpawn,