(Fix) src/components/NewBallot.jsx
This commit is contained in:
parent
8c70c917d2
commit
3ac429875d
|
@ -194,7 +194,7 @@ export class BallotCard extends React.Component {
|
||||||
const msStart = start.diff(_now)
|
const msStart = start.diff(_now)
|
||||||
const msFinish = finish.diff(_now)
|
const msFinish = finish.diff(_now)
|
||||||
|
|
||||||
if (msCancel > 0) {
|
if (msCancel > 0 && !this.isCanceled) {
|
||||||
this.timeToCancel.val = msCancel
|
this.timeToCancel.val = msCancel
|
||||||
this.timeToCancel.displayValue = this.formatMs(msCancel, ':mm:ss')
|
this.timeToCancel.displayValue = this.formatMs(msCancel, ':mm:ss')
|
||||||
} else {
|
} else {
|
||||||
|
@ -202,13 +202,13 @@ export class BallotCard extends React.Component {
|
||||||
this.timeToCancel.displayValue = zeroTimeTo
|
this.timeToCancel.displayValue = zeroTimeTo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msStart > 0) {
|
if (msStart > 0 && !this.isCanceled) {
|
||||||
this.timeToStart.val = msStart + 5000
|
this.timeToStart.val = msStart + 5000
|
||||||
this.timeToStart.displayValue = this.formatMs(msStart, ':mm:ss')
|
this.timeToStart.displayValue = this.formatMs(msStart, ':mm:ss')
|
||||||
return (this.timeTo = this.timeToStart)
|
return (this.timeTo = this.timeToStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msFinish > 0) {
|
if (msFinish > 0 && !this.isCanceled) {
|
||||||
this.timeToStart.val = 0
|
this.timeToStart.val = 0
|
||||||
this.timeToFinish.val = msFinish
|
this.timeToFinish.val = msFinish
|
||||||
this.timeToFinish.displayValue = this.formatMs(msFinish, ':mm:ss')
|
this.timeToFinish.displayValue = this.formatMs(msFinish, ':mm:ss')
|
||||||
|
@ -267,6 +267,10 @@ export class BallotCard extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
vote = async ({ choice }) => {
|
vote = async ({ choice }) => {
|
||||||
|
if (this.isCanceled) {
|
||||||
|
swal('Warning!', messages.INVALID_VOTE_MSG, 'warning')
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.timeToStart.val > 0) {
|
if (this.timeToStart.val > 0) {
|
||||||
swal('Warning!', messages.ballotIsNotActiveMsg(this.timeTo.displayValue), 'warning')
|
swal('Warning!', messages.ballotIsNotActiveMsg(this.timeTo.displayValue), 'warning')
|
||||||
return
|
return
|
||||||
|
@ -522,13 +526,13 @@ export class BallotCard extends React.Component {
|
||||||
contractsStore.ballotCancelingThreshold > 0 &&
|
contractsStore.ballotCancelingThreshold > 0 &&
|
||||||
votingState.creatorMiningKey === contractsStore.miningKey
|
votingState.creatorMiningKey === contractsStore.miningKey
|
||||||
) {
|
) {
|
||||||
|
votingState.creationTime = Number(votingState.creationTime)
|
||||||
this.cancelDeadline = moment
|
this.cancelDeadline = moment
|
||||||
.utc((votingState.creationTime + contractsStore.ballotCancelingThreshold) * 1000)
|
.utc((votingState.creationTime + contractsStore.ballotCancelingThreshold) * 1000)
|
||||||
.format(USDateTimeFormat)
|
.format(USDateTimeFormat)
|
||||||
}
|
}
|
||||||
this.startTime = moment.utc(votingState.startTime * 1000).format(USDateTimeFormat)
|
this.startTime = moment.utc(votingState.startTime * 1000).format(USDateTimeFormat)
|
||||||
this.endTime = moment.utc(votingState.endTime * 1000).format(USDateTimeFormat)
|
this.endTime = moment.utc(votingState.endTime * 1000).format(USDateTimeFormat)
|
||||||
this.calcTimeTo()
|
|
||||||
// getCreator
|
// getCreator
|
||||||
this.creator = votingState.creator
|
this.creator = votingState.creator
|
||||||
this.creatorMiningKey = votingState.creatorMiningKey
|
this.creatorMiningKey = votingState.creatorMiningKey
|
||||||
|
@ -551,6 +555,7 @@ export class BallotCard extends React.Component {
|
||||||
if (votingState.hasOwnProperty('isCanceled')) {
|
if (votingState.hasOwnProperty('isCanceled')) {
|
||||||
this.isCanceled = votingState.isCanceled
|
this.isCanceled = votingState.isCanceled
|
||||||
}
|
}
|
||||||
|
this.calcTimeTo()
|
||||||
// canBeFinalizedNow
|
// canBeFinalizedNow
|
||||||
if (votingState.hasOwnProperty('canBeFinalizedNow')) {
|
if (votingState.hasOwnProperty('canBeFinalizedNow')) {
|
||||||
this.canBeFinalized = votingState.canBeFinalizedNow
|
this.canBeFinalized = votingState.canBeFinalizedNow
|
||||||
|
|
Loading…
Reference in New Issue