Skip to content

Commit

Permalink
fix : Staking lab (#423)
Browse files Browse the repository at this point in the history
* fix: dashboard condition, dispatch lab account

* code: remove console & unused code

* fix: error testing
  • Loading branch information
azmimuhammad authored May 17, 2022
1 parent bc97a92 commit b87c2b6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/router/routes/lab.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const labRoutes = [
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.verificationStatus === "Unverified" &&
(store.state.substrate.labAccount.stakeStatus === "Unstaked" && store.state.substrate.labAccount.stakeAmount === "0")
) {
to.meta.drawerButtons = [
Expand Down
10 changes: 9 additions & 1 deletion src/views/Dashboard/Lab/NavigationLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@status-wallet="({status, img}) => connectWalletResult(status, img)"
></WalletBinding>

<v-main class="main" v-if="(!isServicesExist || (labAccount.stakeStatus === 'Unstaked' && labAccount.unstakeAt === '0')) && isLabDashboard">
<v-main class="main" v-if="(verificationStatus === 'Unverified' && computeStakingStatus) && isLabDashboard">
<router-view />
</v-main>

Expand Down Expand Up @@ -138,6 +138,14 @@ export default {
return this.$route.meta.pageHeader
? this.$route.meta.pageHeader
: v.titleCase(this.$route.name)
},
computeStakingStatus() {
return this.labAccount?.stakeStatus === "Unstaked" && this.labAccount.unstakeAt === "0"
},
verificationStatus() {
return this.labAccount?.verificationStatus
}
},
watch: {
Expand Down
18 changes: 9 additions & 9 deletions src/views/Dashboard/Lab/Registration/Services/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ import { createService, updateService, createServiceFee, updateServiceFee } from
import { getCategories } from "@/lib/api"
import List from "./List"
import Stepper from "../Stepper"
import { queryLabsById } from "@/lib/polkadotProvider/query/labs"
import { stakeLab } from "@/lib/polkadotProvider/command/labs"
import DialogAlert from "@/components/Dialog/DialogAlert"
import DialogStake from "@/components/Dialog/DialogStake"
Expand All @@ -266,7 +265,6 @@ import { sendEmailRegisteredLab } from "@/lib/api/lab"
import rulesHandler from "@/constants/rules"
import { generalDebounce } from "@/utils"
export default {
name: "LabRegistrationServices",
Expand Down Expand Up @@ -420,7 +418,6 @@ export default {
},
methods: {
async getServiceCategory() {
const { data : data } = await getCategories()
this.listCategories = data
Expand All @@ -442,25 +439,26 @@ export default {
async actionAlert() {
this.isSubmiting = true
const currentLab = await queryLabsById(this.api, this.wallet.address)
if (this.isLabExist && currentLab.verificationStatus === "Unverified") {
const {labAccount} = await this.$store.dispatch("substrate/getLabAccount")
if (this.isLabExist && labAccount.verificationStatus === "Unverified") {
await sendEmailRegisteredLab(this.wallet.address)
this.$store.dispatch("substrate/addAnyNotification", {
await this.$store.dispatch("substrate/addAnyNotification", {
address: this.wallet.address,
dataAdd: {
message: "Congrats! You have been submitted your account verification.",
data: currentLab,
data: labAccount,
route: null,
params: null
},
role: "lab"
})
this.isSubmiting = false
this.dialogAlert = true
this.isSubmiting = false
}
this.gotoDashboard()
},
Expand All @@ -471,6 +469,8 @@ export default {
await stakeLab(this.api, this.pair)
this.actionAlert()
await this.$store.dispatch("substrate/getLabAccount")
this.gotoDashboard()
} catch (error) {
console.error(error)
}
Expand Down
15 changes: 9 additions & 6 deletions src/views/Dashboard/Lab/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</style>

<template>
<v-container :class="!isServicesExist || computeStakingStatus ? 'center-all' : ''">
<v-container v-if="!isServicesExist || computeStakingStatus">
<v-container :class="verificationStatus === 'Unverified' && computeStakingStatus ? 'center-all' : ''">
<v-container v-if="verificationStatus === 'Unverified' && computeStakingStatus">
<h1 class="title-text-color">You don't have a lab account yet</h1>
<v-btn color="primary" to="/lab/registration">
{{ computeStakingStatus ? "Continue Registration" : "Register Now!" }}
Expand All @@ -39,15 +39,15 @@
inline
color="primary"
:size="20"
v-if="labAccount && labAccount.verificationStatus == 'Verified'"
v-if="labAccount && verificationStatus == 'Verified'"
>mdi-check-decagram</v-icon>
<v-icon
inline
color="yellow darken-2"
:size="20"
v-else
>mdi-information</v-icon>
<b v-if="labAccount && labAccount.verificationStatus == 'Unverified'">Your verification submission is being reviewed by DAOGenics</b>
<b v-if="labAccount && verificationStatus == 'Unverified'">Your verification submission is being reviewed by DAOGenics</b>
<b v-else>{{ computeVerificationStatus }}</b>
</div>
</v-card>
Expand Down Expand Up @@ -100,10 +100,13 @@ export default {
computed: {
...mapState({
labAccount: (state) => state.substrate.labAccount,
isServicesExist: (state) => state.substrate.isServicesExist
labAccount: (state) => state.substrate.labAccount
}),
verificationStatus() {
return this.labAccount?.verificationStatus
},
computeVerificationStatus() {
return this.labAccount?.verificationStatus
? `Your lab account's verification status is: ${this.labAccount?.verificationStatus}`
Expand Down

0 comments on commit b87c2b6

Please sign in to comment.