classic-ui/pages/governance.vue

46 lines
1016 B
Vue
Raw Normal View History

2022-04-22 06:05:56 +03:00
<template>
<div class="main">
<Metrics />
<nuxt-child />
</div>
</template>
<script>
import { mapActions, mapState, mapGetters } from 'vuex'
import Metrics from '@/components/governance/Metrics'
export default {
middleware({ store, error }) {
if (!store.getters['governance/gov/isEnabledGovernance']) {
2022-05-27 12:28:20 +03:00
return error({ statusCode: 204, pageName: 'governance' })
2022-04-22 06:05:56 +03:00
}
},
components: {
Metrics
},
computed: {
...mapState('metamask', ['isInitialized']),
...mapGetters('governance/gov', ['isEnabledGovernance'])
},
watch: {
isInitialized: {
handler() {
2022-05-27 12:28:20 +03:00
if (this.isEnabledGovernance) {
this.fetchProposals({})
this.fetchConstants()
}
2022-04-22 06:05:56 +03:00
},
immediate: true
},
isEnabledGovernance(isEnabled) {
if (!isEnabled) {
2022-05-27 12:28:20 +03:00
this.$nuxt.error({ statusCode: 204, pageName: 'governance' })
2022-04-22 06:05:56 +03:00
}
}
},
methods: {
...mapActions('governance/gov', ['fetchProposals', 'fetchConstants'])
}
}
</script>