14 days upper limit for ballot's duration (#109)
This commit is contained in:
parent
e45bcc2eb8
commit
9f72ef8a00
|
@ -20,7 +20,7 @@ export class NewBallot extends React.Component {
|
|||
const { commonStore, contractsStore, ballotStore, validatorStore } = this.props;
|
||||
const twoDays = moment.utc().add(2, 'days').format();
|
||||
let neededMinutes = moment(twoDays).diff(moment(ballotStore.endTime), 'minutes');
|
||||
let neededHours = Math.round(neededMinutes/60);
|
||||
let neededHours = Math.round(neededMinutes / 60);
|
||||
let duration = 48 - neededHours;
|
||||
|
||||
if (ballotStore.isNewValidatorPersonalData) {
|
||||
|
@ -33,19 +33,27 @@ export class NewBallot extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
if(!ballotStore.memo){
|
||||
if(!ballotStore.memo) {
|
||||
swal("Warning!", messages.DESCRIPTION_IS_EMPTY, "warning");
|
||||
commonStore.hideLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(neededMinutes > 0) {
|
||||
neededMinutes = neededHours*60 - neededMinutes;
|
||||
neededMinutes = neededHours * 60 - neededMinutes;
|
||||
swal("Warning!", messages.SHOULD_BE_MORE_THAN_TWO_DAYS(duration, neededHours, neededMinutes), "warning");
|
||||
commonStore.hideLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
const twoWeeks = moment.utc().add(14, 'days').format();
|
||||
let exceededMinutes = moment(ballotStore.endTime).diff(moment(twoWeeks), 'minutes');
|
||||
if (exceededMinutes > 0) {
|
||||
swal("Warning!", messages.SHOULD_BE_LESS_OR_EQUAL_14_DAYS(duration), "warning");
|
||||
commonStore.hideLoading();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ballotStore.isBallotForKey) {
|
||||
for (let ballotKeysProp in ballotStore.ballotKeys) {
|
||||
if (!ballotStore.ballotKeys[ballotKeysProp]) {
|
||||
|
|
|
@ -27,6 +27,9 @@ messages.SHOULD_BE_MORE_THAN_TWO_DAYS = (duration, neededHours, neededMinutes) =
|
|||
Please add ${neededHours} hours and ${neededMinutes} minutes in order to set correct end time
|
||||
`;
|
||||
}
|
||||
messages.SHOULD_BE_LESS_OR_EQUAL_14_DAYS = (duration) => {
|
||||
return `Ballot end time should not be more than 14 days from now in UTC time. Current duration is ${duration} hours.`;
|
||||
}
|
||||
messages.FAILED_TX = `Your transaction was failed. Please make sure you set correct parameters for ballot creation.
|
||||
Make sure you don't have Transaction Error. Exception thrown in contract code message in metamask before you sign it.`
|
||||
messages.DESCRIPTION_IS_EMPTY = "Description cannot be empty";
|
||||
|
|
Loading…
Reference in New Issue