Skip to content

Commit

Permalink
Don't continue to step 4 if min cap is not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Mar 2, 2018
1 parent c862894 commit daa8d1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/components/stepThree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,24 @@ export class stepThree extends React.Component {

const { tierStore, gasPriceStore } = this.props;
const gasPriceIsValid = gasPriceStore.custom.id !== this.state.gasPriceSelected || this.state.validation.gasPrice.valid === VALID

console.log('gasPriceIsValid', gasPriceIsValid)
const isMinCapValid = tierStore.globalMinCap <= tierStore.minSupply

for (let index = 0; index < tierStore.tiers.length; index++) {
tierStore.validateTiers("endTime", index);
tierStore.validateTiers("startTime", index);
}

if (tierStore.areTiersValid && gasPriceIsValid) {
if (!isMinCapValid) {
this.setState(update(this.state, {
validation: {
minCap: {
valid: { $set: INVALID }
}
}
}))
}

if (tierStore.areTiersValid && gasPriceIsValid && isMinCapValid) {
const { reservedTokenStore, deploymentStore } = this.props
const tiersCount = tierStore.tiers.length
const reservedCount = reservedTokenStore.tokens.length
Expand Down
4 changes: 4 additions & 0 deletions src/stores/TierStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ class TierStore {
whitelist[whitelistNum].deleted = true
this.setTierProperty(whitelist, 'whitelist', crowdsaleNum)
}

@computed get minSupply () {
return this.tiers.map(tier => +tier.supply).reduce((a, b) => Math.min(a, b))
}
}

export default TierStore;
2 changes: 1 addition & 1 deletion src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const VALIDATION_MESSAGES = {
EDITED_END_TIME: 'Please enter a valid date later than start time and previous than start time of next tier',
EDITED_START_TIME: 'Please enter a valid date later than now, less than end time and later than the end time of the previous tier',
RATE: 'Please enter a valid number greater than 0',
MINCAP: 'Value must be positive and decimals should not exceed the amount of decimals specified'
MINCAP: 'Value must be positive, decimals should not exceed the amount of decimals specified and min cap should be less or equal than the smaller supply'
}

//descriptions of input fields
Expand Down

0 comments on commit daa8d1c

Please sign in to comment.