(Fix) Refresh ballot card after voting or finalization
This commit is contained in:
parent
9f89940b0f
commit
db743f3e5a
|
@ -11,7 +11,7 @@ const USDateTimeFormat = "MM/DD/YYYY h:mm:ss A";
|
||||||
|
|
||||||
const zeroTimeTo = "00:00";
|
const zeroTimeTo = "00:00";
|
||||||
|
|
||||||
@inject("commonStore", "contractsStore", "routing")
|
@inject("commonStore", "contractsStore", "routing", "ballotsStore")
|
||||||
@observer
|
@observer
|
||||||
export class BallotCard extends React.Component {
|
export class BallotCard extends React.Component {
|
||||||
@observable startTime;
|
@observable startTime;
|
||||||
|
@ -167,7 +167,7 @@ export class BallotCard extends React.Component {
|
||||||
swal("Warning!", messages.ballotIsNotActiveMsg(this.timeTo.displayValue), "warning");
|
swal("Warning!", messages.ballotIsNotActiveMsg(this.timeTo.displayValue), "warning");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { commonStore, contractsStore, id, votingType } = this.props;
|
const { commonStore, contractsStore, id, votingType, ballotsStore } = this.props;
|
||||||
const { push } = this.props.routing;
|
const { push } = this.props.routing;
|
||||||
if (!contractsStore.isValidVotingKey) {
|
if (!contractsStore.isValidVotingKey) {
|
||||||
swal("Warning!", messages.invalidVotingKeyMsg(contractsStore.votingKey), "warning");
|
swal("Warning!", messages.invalidVotingKeyMsg(contractsStore.votingKey), "warning");
|
||||||
|
@ -187,16 +187,22 @@ export class BallotCard extends React.Component {
|
||||||
if (tx.status === true || tx.status === '0x1') {
|
if (tx.status === true || tx.status === '0x1') {
|
||||||
const ballotInfo = await contract.getBallotInfo(id, contractsStore.votingKey);
|
const ballotInfo = await contract.getBallotInfo(id, contractsStore.votingKey);
|
||||||
|
|
||||||
this.totalVoters = ballotInfo.totalVoters;
|
this.totalVoters = Number(ballotInfo.totalVoters);
|
||||||
this.progress = ballotInfo.progress;
|
this.progress = Number(ballotInfo.progress);
|
||||||
this.isFinalized = ballotInfo.isFinalized;
|
this.isFinalized = Boolean(ballotInfo.isFinalized);
|
||||||
if (ballotInfo.hasOwnProperty('canBeFinalizedNow')) {
|
if (ballotInfo.hasOwnProperty('canBeFinalizedNow')) {
|
||||||
this.canBeFinalized = ballotInfo.canBeFinalizedNow;
|
this.canBeFinalized = Boolean(ballotInfo.canBeFinalizedNow);
|
||||||
} else {
|
} else {
|
||||||
await this.canBeFinalizedNow();
|
await this.canBeFinalizedNow();
|
||||||
}
|
}
|
||||||
this.hasAlreadyVoted = true;
|
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) => {
|
swal("Congratulations!", messages.VOTED_SUCCESS_MSG, "success").then((result) => {
|
||||||
push(`${commonStore.rootPath}`);
|
push(`${commonStore.rootPath}`);
|
||||||
});
|
});
|
||||||
|
@ -220,7 +226,7 @@ export class BallotCard extends React.Component {
|
||||||
swal("Warning!", messages.ballotIsNotActiveMsg(this.timeTo.displayValue), "warning");
|
swal("Warning!", messages.ballotIsNotActiveMsg(this.timeTo.displayValue), "warning");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { commonStore, contractsStore, id, votingType } = this.props;
|
const { commonStore, contractsStore, id, votingType, ballotsStore } = this.props;
|
||||||
const { push } = this.props.routing;
|
const { push } = this.props.routing;
|
||||||
if (!contractsStore.isValidVotingKey) {
|
if (!contractsStore.isValidVotingKey) {
|
||||||
swal("Warning!", messages.invalidVotingKeyMsg(contractsStore.votingKey), "warning");
|
swal("Warning!", messages.invalidVotingKeyMsg(contractsStore.votingKey), "warning");
|
||||||
|
@ -246,9 +252,9 @@ export class BallotCard extends React.Component {
|
||||||
.on("receipt", (tx) => {
|
.on("receipt", (tx) => {
|
||||||
commonStore.hideLoading();
|
commonStore.hideLoading();
|
||||||
if (tx.status === true || tx.status === '0x1') {
|
if (tx.status === true || tx.status === '0x1') {
|
||||||
this.isFinalized = true;
|
ballotsStore.ballotCards[this.props.pos].props.votingState.isFinalized = true;
|
||||||
if (this.canBeFinalized !== null) {
|
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) => {
|
swal("Congratulations!", messages.FINALIZED_SUCCESS_MSG, "success").then((result) => {
|
||||||
push(`${commonStore.rootPath}`);
|
push(`${commonStore.rootPath}`);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { BallotCard } from "./BallotCard";
|
||||||
@observer
|
@observer
|
||||||
export class BallotKeysCard extends React.Component {
|
export class BallotKeysCard extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
let { id, votingState } = this.props;
|
let { id, votingState, pos } = this.props;
|
||||||
|
|
||||||
let affectedKeyClassName;
|
let affectedKeyClassName;
|
||||||
let affectedKey = <p>{votingState.affectedKey}</p>;
|
let affectedKey = <p>{votingState.affectedKey}</p>;
|
||||||
|
@ -33,7 +33,7 @@ export class BallotKeysCard extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BallotCard votingType="votingToChangeKeys" votingState={votingState} id={id}>
|
<BallotCard votingType="votingToChangeKeys" votingState={votingState} id={id} pos={pos}>
|
||||||
<div className="ballots-about-i ballots-about-i_action">
|
<div className="ballots-about-i ballots-about-i_action">
|
||||||
<div className="ballots-about-td">
|
<div className="ballots-about-td">
|
||||||
<p className="ballots-about-i--title">Action</p>
|
<p className="ballots-about-i--title">Action</p>
|
||||||
|
|
|
@ -6,9 +6,9 @@ import { BallotCard } from "./BallotCard";
|
||||||
@observer
|
@observer
|
||||||
export class BallotMinThresholdCard extends React.Component {
|
export class BallotMinThresholdCard extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
let { id, votingState } = this.props;
|
let { id, votingState, pos } = this.props;
|
||||||
return (
|
return (
|
||||||
<BallotCard votingType="votingToChangeMinThreshold" votingState={votingState} id={id}>
|
<BallotCard votingType="votingToChangeMinThreshold" votingState={votingState} id={id} pos={pos}>
|
||||||
<div className="ballots-about-i ballots-about-i_proposed-min-threshold">
|
<div className="ballots-about-i ballots-about-i_proposed-min-threshold">
|
||||||
<div className="ballots-about-td">
|
<div className="ballots-about-td">
|
||||||
<p className="ballots-about-i--title">Proposed min threshold</p>
|
<p className="ballots-about-i--title">Proposed min threshold</p>
|
||||||
|
|
|
@ -6,9 +6,9 @@ import { BallotCard } from "./BallotCard";
|
||||||
@observer
|
@observer
|
||||||
export class BallotProxyCard extends React.Component {
|
export class BallotProxyCard extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const { id, votingState } = this.props;
|
const { id, votingState, pos } = this.props;
|
||||||
return (
|
return (
|
||||||
<BallotCard votingType="votingToChangeProxy" votingState={votingState} id={id}>
|
<BallotCard votingType="votingToChangeProxy" votingState={votingState} id={id} pos={pos}>
|
||||||
<div className="ballots-about-i ballots-about-i_contract-type">
|
<div className="ballots-about-i ballots-about-i_contract-type">
|
||||||
<div className="ballots-about-td">
|
<div className="ballots-about-td">
|
||||||
<p className="ballots-about-i--title">Contract type</p>
|
<p className="ballots-about-i--title">Contract type</p>
|
||||||
|
|
|
@ -271,6 +271,7 @@ class ContractsStore {
|
||||||
id={id}
|
id={id}
|
||||||
type={ballotStore.BallotType.keys}
|
type={ballotStore.BallotType.keys}
|
||||||
key={ballotsStore.ballotCards.length}
|
key={ballotsStore.ballotCards.length}
|
||||||
|
pos={ballotsStore.ballotCards.length}
|
||||||
votingState={votingState}/>
|
votingState={votingState}/>
|
||||||
break;
|
break;
|
||||||
case "votingToChangeMinThreshold":
|
case "votingToChangeMinThreshold":
|
||||||
|
@ -278,6 +279,7 @@ class ContractsStore {
|
||||||
id={id}
|
id={id}
|
||||||
type={ballotStore.BallotType.minThreshold}
|
type={ballotStore.BallotType.minThreshold}
|
||||||
key={ballotsStore.ballotCards.length}
|
key={ballotsStore.ballotCards.length}
|
||||||
|
pos={ballotsStore.ballotCards.length}
|
||||||
votingState={votingState}/>
|
votingState={votingState}/>
|
||||||
break;
|
break;
|
||||||
case "votingToChangeProxy":
|
case "votingToChangeProxy":
|
||||||
|
@ -285,6 +287,7 @@ class ContractsStore {
|
||||||
id={id}
|
id={id}
|
||||||
type={ballotStore.BallotType.proxy}
|
type={ballotStore.BallotType.proxy}
|
||||||
key={ballotsStore.ballotCards.length}
|
key={ballotsStore.ballotCards.length}
|
||||||
|
pos={ballotsStore.ballotCards.length}
|
||||||
votingState={votingState}/>
|
votingState={votingState}/>
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue