Skip to content

Commit

Permalink
fix(plan manager): show correct amount of tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenijesavic committed Jan 19, 2023
1 parent 0353d90 commit 37b7691
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/components/dao/settings-plan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default {
canActivate () { return this.form.plan !== null && this.form.period !== null },
planChipName () { return this.selectedDaoPlan.hasExpired ? 'Suspended' : (this.selectedDaoPlan.isExpiring ? 'Expired' : 'Plan active') },
planChipColor () { return this.selectedDaoPlan.hasExpired ? 'negative' : (this.selectedDaoPlan.isExpiring ? 'negative' : 'secondary') },
hasEnoughTokens () { return this.balances?.[0]?.amount >= this.tokenAmount },
hasEnoughTokens () { return Number(this.balances?.[0]?.amount) >= this.tokenAmount },
PLANS () {
// eslint-disable-next-line no-unused-expressions
this.usdPerHypha // Here just to force reload
Expand Down Expand Up @@ -168,19 +168,17 @@ export default {
},
async openActivateModal () {
const selector = {
Thrive: 'Growth Starter Founders',
Growth: 'Starter Founders',
Starter: 'Founders'
}
const currentPlanName = this.selectedDaoPlan.name
const selectedPlanName = this.selectedPlan.name
if (selector[currentPlanName].includes(selectedPlanName)) {
const activePlanIndex = this.PLANS.findIndex(_ => _.name === this.selectedDaoPlan.name)
const selectedPlanIndex = this.PLANS.findIndex(_ => _.id === this.form.plan)
const isDowngrading = activePlanIndex > selectedPlanIndex
if (isDowngrading) {
this.state = 'DOWNGRADING'
} else {
await this.activatePlan()
}
},
async activatePlan () {
const data = {
account: this.account,
Expand All @@ -190,6 +188,7 @@ export default {
offerId: this.selectedBilling.id,
periods: this.selectedBilling.periods
}
try {
await this.activateDAOPlan(data)
this.state = 'ACTIVE'
Expand All @@ -208,9 +207,6 @@ export default {
async beforeMount () {
this.usdPerHypha = await this.getUSDPerHypha()
},
create () {
this.fetchHyphaBalance(this.account)
this.form.plan = this.pageQuery.plans.find(_ => _.name === this.selectedDaoPlan.name).id
if (this.selectedPlan.name !== 'Founders' && (this.selectedDaoPlan.hasExpired || this.selectedDaoPlan.isExpiring)) {
Expand Down

0 comments on commit 37b7691

Please sign in to comment.