diff --git a/src/components/BallotKeysMetadata.jsx b/src/components/BallotKeysMetadata.jsx index 9468d19..438aed0 100644 --- a/src/components/BallotKeysMetadata.jsx +++ b/src/components/BallotKeysMetadata.jsx @@ -43,7 +43,8 @@ export class BallotKeysMetadata extends React.Component {
ballotStore.changeBallotMetadata(e, "endTime")} />

diff --git a/src/components/NewBallot.jsx b/src/components/NewBallot.jsx index 45ff830..6248a31 100644 --- a/src/components/NewBallot.jsx +++ b/src/components/NewBallot.jsx @@ -8,7 +8,6 @@ import { BallotKeysMetadata } from './BallotKeysMetadata'; import { BallotMinThresholdMetadata } from './BallotMinThresholdMetadata'; import { BallotProxyMetadata } from './BallotProxyMetadata'; import { messages } from "../messages"; - @inject("commonStore", "ballotStore", "validatorStore", "contractsStore", "routing") @observer export class NewBallot extends React.Component { @@ -19,8 +18,10 @@ export class NewBallot extends React.Component { checkValidation() { const { commonStore, contractsStore, ballotStore, validatorStore } = this.props; - const isAfter = moment(ballotStore.endTime).isAfter(moment()); - const isTwoDaysMinimum = moment(ballotStore.endTime).isAfter(moment().add(2, 'days')); + const twoDays = moment.utc().add(2, 'days').format(); + let neededMinutes = moment(twoDays).diff(moment(ballotStore.endTime), 'minutes'); + let neededHours = Math.round(neededMinutes/60); + let duration = 48 - neededHours; if (ballotStore.isNewValidatorPersonalData) { for (let validatorProp in validatorStore) { @@ -32,20 +33,15 @@ export class NewBallot extends React.Component { } } - if (!isAfter) { - swal("Warning!", messages.END_TIME_SHOULD_BE_GREATER_THAN_NOW_MSG, "warning"); - commonStore.hideLoading(); - return false; - } - if(!ballotStore.memo){ swal("Warning!", messages.DESCRIPTION_IS_EMPTY, "warning"); commonStore.hideLoading(); return false; } - if(!isTwoDaysMinimum) { - swal("Warning!", messages.SHOULD_BE_MORE_THAN_TWO_DAYS, "warning"); + if(neededMinutes > 0) { + neededMinutes = neededHours*60 - neededMinutes; + swal("Warning!", messages.SHOULD_BE_MORE_THAN_TWO_DAYS(duration, neededHours, neededMinutes), "warning"); commonStore.hideLoading(); return false; } @@ -189,8 +185,7 @@ export class NewBallot extends React.Component { default: break; } - const curDate = new Date(); - let curDateInSeconds = moment(curDate).add(5, 'minute').unix(); + let curDateInSeconds = moment.utc().add(5, 'minute').unix(); methodToCreateBallot(curDateInSeconds) .on("receipt", () => { commonStore.hideLoading(); diff --git a/src/messages.js b/src/messages.js index c28b4c9..2c319b5 100644 --- a/src/messages.js +++ b/src/messages.js @@ -21,7 +21,11 @@ Check POA Network wi messages.ballotIsNotActiveMsg = function(timeToStart) { return `The ballot is not active yet. Time to start: ${timeToStart}`; }; -messages.SHOULD_BE_MORE_THAN_TWO_DAYS = "Ballot end time should be at least 48 hours from now"; +messages.SHOULD_BE_MORE_THAN_TWO_DAYS = (duration, neededHours, neededMinutes) => { + return `Ballot end time should be at least 48 hours from now in UTC time. Current duration is ${duration} hours. + Please add ${neededHours} hours and ${neededMinutes} minutes in order to set correct end time + `; +} messages.DESCRIPTION_IS_EMPTY = "Description cannot be empty"; module.exports = { messages diff --git a/src/stores/BallotStore.js b/src/stores/BallotStore.js index 991e602..6e6e6a5 100644 --- a/src/stores/BallotStore.js +++ b/src/stores/BallotStore.js @@ -35,8 +35,9 @@ class BallotStore { constructor() { + const twoDays = moment().add(2, 'days').add(10, 'minutes').format("YYYY-MM-DDTHH:mm"); this.ballotType = null; - this.endTime = ""; + this.endTime = twoDays; this.ballotKeys = { keyType: null,