(Fix) Add front end validation
This commit is contained in:
parent
5b733c438a
commit
55d8c5632c
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
};
|
|
@ -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})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue