(Fix) Add front end validation

This commit is contained in:
Roman Storm 2018-01-19 19:03:26 -08:00
parent 5b733c438a
commit 55d8c5632c
3 changed files with 21 additions and 0 deletions

View File

@ -20,6 +20,7 @@ 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'));
if (ballotStore.isNewValidatorPersonalData) {
for (let validatorProp in validatorStore) {
@ -37,6 +38,18 @@ export class NewBallot extends React.Component {
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");
commonStore.hideLoading();
return false;
}
if (ballotStore.isBallotForKey) {
for (let ballotKeysProp in ballotStore.ballotKeys) {
if (ballotStore.ballotKeys[ballotKeysProp].length === 0) {

View File

@ -21,6 +21,8 @@ Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>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.DESCRIPTION_IS_EMPTY = "Description cannot be empty";
module.exports = {
messages
};

View File

@ -193,11 +193,17 @@ class ContractsStore {
@action
async getAllValidatorMetadata() {
const newMiningKey = {
label: "New Mining Key",
value: "0x0000000000000000000000000000000000000000"
}
this.validatorsMetadata.push(newMiningKey);
const keys = await this.poaConsensus.getValidators();
keys.forEach(async (key) => {
const metadata = await this.validatorMetadata.getValidatorData({miningKey: key})
this.validatorsMetadata.push({label: `${key} ${metadata.lastName}`, value: key})
})
}
}