From f8aecaff9b2a355f7f80aa6fd3953ab1b991ef76 Mon Sep 17 00:00:00 2001 From: Azmi Muhammad <31072582+azmimuhammad@users.noreply.github.com> Date: Wed, 18 May 2022 12:16:48 +0700 Subject: [PATCH] fix: flow after staking success (#424) * fix: flow after staking success * code: delete unused code --- src/router/routes/lab.js | 4 +- src/views/Dashboard/Lab/NavigationLayout.vue | 11 ++-- .../Lab/Registration/Services/index.vue | 51 ++++++++----------- src/views/Dashboard/Lab/index.vue | 18 +++++-- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/router/routes/lab.js b/src/router/routes/lab.js index b6503e82..20d42435 100644 --- a/src/router/routes/lab.js +++ b/src/router/routes/lab.js @@ -16,9 +16,7 @@ const labRoutes = [ component: () => import(/* webpackChunkName */ "@/views/Dashboard/Lab"), beforeEnter: (to, from, next) => { // Set drawer buttons here to make it dynamic :) - if (!store.state.substrate.isServicesExist || - store.state.substrate.labAccount.verificationStatus === "Unverified" && - (store.state.substrate.labAccount.stakeStatus === "Unstaked" && store.state.substrate.labAccount.stakeAmount === "0") + if (!store.state.substrate.isServicesExist || store.state.substrate.labAccount.verificationStatus === "Unverified" ) { to.meta.drawerButtons = [ { text: "Dashboard", active: true, disabled: false, route: { name: "lab-dashboard" } }, diff --git a/src/views/Dashboard/Lab/NavigationLayout.vue b/src/views/Dashboard/Lab/NavigationLayout.vue index 200c9607..f02ba4e1 100644 --- a/src/views/Dashboard/Lab/NavigationLayout.vue +++ b/src/views/Dashboard/Lab/NavigationLayout.vue @@ -38,7 +38,7 @@ @status-wallet="({status, img}) => connectWalletResult(status, img)" > - + @@ -141,11 +141,14 @@ export default { }, computeStakingStatus() { - return this.labAccount?.stakeStatus === "Unstaked" && this.labAccount.unstakeAt === "0" + return this.labAccount?.stakeStatus === "Unstaked" }, - verificationStatus() { - return this.labAccount?.verificationStatus + allowDashboard() { + if (this.isServicesExist) + if (this.labAccount?.stakeStatus === "Unstaked" && this.labAccount?.verificationStatus === "Unverified") return false + else return true + else return false } }, watch: { diff --git a/src/views/Dashboard/Lab/Registration/Services/index.vue b/src/views/Dashboard/Lab/Registration/Services/index.vue index 636c71d2..123e176e 100644 --- a/src/views/Dashboard/Lab/Registration/Services/index.vue +++ b/src/views/Dashboard/Lab/Registration/Services/index.vue @@ -433,48 +433,39 @@ export default { } }, - gotoDashboard() { + async gotoDashboard() { + await this.$store.dispatch("substrate/getLabAccount") this.$router.push({ name: "lab-dashboard" }) }, - async actionAlert() { - this.isSubmiting = true - const {labAccount} = await this.$store.dispatch("substrate/getLabAccount") - - if (this.isLabExist && labAccount.verificationStatus === "Unverified") { - await sendEmailRegisteredLab(this.wallet.address) - - await this.$store.dispatch("substrate/addAnyNotification", { - address: this.wallet.address, - dataAdd: { - message: "Congrats! You have been submitted your account verification.", - data: labAccount, - route: null, - params: null - }, - role: "lab" - }) - - this.dialogAlert = true - this.isSubmiting = false - } - - this.gotoDashboard() - }, - async handleStakeLab() { + this.isSubmiting = true this.stakeLoading = true try { await stakeLab(this.api, this.pair) - - this.actionAlert() - await this.$store.dispatch("substrate/getLabAccount") - this.gotoDashboard() + const {labAccount} = await this.$store.dispatch("substrate/getLabAccount") + + if (this.isLabExist && labAccount.verificationStatus === "Unverified") { + await sendEmailRegisteredLab(this.wallet.address) + + this.$store.dispatch("substrate/addAnyNotification", { + address: this.wallet.address, + dataAdd: { + message: "Congrats! You have been submitted your account verification.", + data: labAccount, + route: null, + params: null + }, + role: "lab" + }) + } + this.dialogAlert = true } catch (error) { console.error(error) } + this.isSubmiting = false this.stakeLoading = false }, diff --git a/src/views/Dashboard/Lab/index.vue b/src/views/Dashboard/Lab/index.vue index fd59183a..6dd01bea 100644 --- a/src/views/Dashboard/Lab/index.vue +++ b/src/views/Dashboard/Lab/index.vue @@ -24,8 +24,8 @@