diff --git a/src/components/BallotCard.jsx b/src/components/BallotCard.jsx index 3a77bbd..1bf441e 100644 --- a/src/components/BallotCard.jsx +++ b/src/components/BallotCard.jsx @@ -11,7 +11,7 @@ const USDateTimeFormat = "MM/DD/YYYY h:mm:ss A"; const zeroTimeTo = "00:00"; -@inject("commonStore", "contractsStore", "routing") +@inject("commonStore", "contractsStore", "routing", "ballotsStore") @observer export class BallotCard extends React.Component { @observable startTime; @@ -167,7 +167,7 @@ export class BallotCard extends React.Component { swal("Warning!", messages.ballotIsNotActiveMsg(this.timeTo.displayValue), "warning"); return; } - const { commonStore, contractsStore, id, votingType } = this.props; + const { commonStore, contractsStore, id, votingType, ballotsStore } = this.props; const { push } = this.props.routing; if (!contractsStore.isValidVotingKey) { swal("Warning!", messages.invalidVotingKeyMsg(contractsStore.votingKey), "warning"); @@ -187,16 +187,22 @@ export class BallotCard extends React.Component { if (tx.status === true || tx.status === '0x1') { const ballotInfo = await contract.getBallotInfo(id, contractsStore.votingKey); - this.totalVoters = ballotInfo.totalVoters; - this.progress = ballotInfo.progress; - this.isFinalized = ballotInfo.isFinalized; + this.totalVoters = Number(ballotInfo.totalVoters); + this.progress = Number(ballotInfo.progress); + this.isFinalized = Boolean(ballotInfo.isFinalized); if (ballotInfo.hasOwnProperty('canBeFinalizedNow')) { - this.canBeFinalized = ballotInfo.canBeFinalizedNow; + this.canBeFinalized = Boolean(ballotInfo.canBeFinalizedNow); } else { await this.canBeFinalizedNow(); } this.hasAlreadyVoted = true; + ballotsStore.ballotCards[this.props.pos].props.votingState.totalVoters = this.totalVoters; + ballotsStore.ballotCards[this.props.pos].props.votingState.progress = this.progress; + ballotsStore.ballotCards[this.props.pos].props.votingState.isFinalized = this.isFinalized; + ballotsStore.ballotCards[this.props.pos].props.votingState.canBeFinalized = this.canBeFinalized; + ballotsStore.ballotCards[this.props.pos].props.votingState.hasAlreadyVoted = this.hasAlreadyVoted; + swal("Congratulations!", messages.VOTED_SUCCESS_MSG, "success").then((result) => { push(`${commonStore.rootPath}`); }); @@ -220,7 +226,7 @@ export class BallotCard extends React.Component { swal("Warning!", messages.ballotIsNotActiveMsg(this.timeTo.displayValue), "warning"); return; } - const { commonStore, contractsStore, id, votingType } = this.props; + const { commonStore, contractsStore, id, votingType, ballotsStore } = this.props; const { push } = this.props.routing; if (!contractsStore.isValidVotingKey) { swal("Warning!", messages.invalidVotingKeyMsg(contractsStore.votingKey), "warning"); @@ -246,9 +252,9 @@ export class BallotCard extends React.Component { .on("receipt", (tx) => { commonStore.hideLoading(); if (tx.status === true || tx.status === '0x1') { - this.isFinalized = true; + ballotsStore.ballotCards[this.props.pos].props.votingState.isFinalized = true; if (this.canBeFinalized !== null) { - this.canBeFinalized = false; + ballotsStore.ballotCards[this.props.pos].props.votingState.canBeFinalized = false; } swal("Congratulations!", messages.FINALIZED_SUCCESS_MSG, "success").then((result) => { push(`${commonStore.rootPath}`); diff --git a/src/components/BallotKeysCard.jsx b/src/components/BallotKeysCard.jsx index 110bd3c..fe9cf20 100644 --- a/src/components/BallotKeysCard.jsx +++ b/src/components/BallotKeysCard.jsx @@ -6,7 +6,7 @@ import { BallotCard } from "./BallotCard"; @observer export class BallotKeysCard extends React.Component { render () { - let { id, votingState } = this.props; + let { id, votingState, pos } = this.props; let affectedKeyClassName; let affectedKey =

{votingState.affectedKey}

; @@ -33,7 +33,7 @@ export class BallotKeysCard extends React.Component { } return ( - +

Action

diff --git a/src/components/BallotMinThresholdCard.jsx b/src/components/BallotMinThresholdCard.jsx index 1158957..855159f 100644 --- a/src/components/BallotMinThresholdCard.jsx +++ b/src/components/BallotMinThresholdCard.jsx @@ -6,9 +6,9 @@ import { BallotCard } from "./BallotCard"; @observer export class BallotMinThresholdCard extends React.Component { render () { - let { id, votingState } = this.props; + let { id, votingState, pos } = this.props; return ( - +

Proposed min threshold

diff --git a/src/components/BallotProxyCard.jsx b/src/components/BallotProxyCard.jsx index 6801b24..c19694a 100644 --- a/src/components/BallotProxyCard.jsx +++ b/src/components/BallotProxyCard.jsx @@ -6,9 +6,9 @@ import { BallotCard } from "./BallotCard"; @observer export class BallotProxyCard extends React.Component { render () { - const { id, votingState } = this.props; + const { id, votingState, pos } = this.props; return ( - +

Contract type

diff --git a/src/stores/ContractsStore.js b/src/stores/ContractsStore.js index 7fad8f2..6ff3990 100644 --- a/src/stores/ContractsStore.js +++ b/src/stores/ContractsStore.js @@ -271,6 +271,7 @@ class ContractsStore { id={id} type={ballotStore.BallotType.keys} key={ballotsStore.ballotCards.length} + pos={ballotsStore.ballotCards.length} votingState={votingState}/> break; case "votingToChangeMinThreshold": @@ -278,6 +279,7 @@ class ContractsStore { id={id} type={ballotStore.BallotType.minThreshold} key={ballotsStore.ballotCards.length} + pos={ballotsStore.ballotCards.length} votingState={votingState}/> break; case "votingToChangeProxy": @@ -285,6 +287,7 @@ class ContractsStore { id={id} type={ballotStore.BallotType.proxy} key={ballotsStore.ballotCards.length} + pos={ballotsStore.ballotCards.length} votingState={votingState}/> break; default: