classic-ui/pages/governance.vue

46 lines
1016 B
Vue
Raw Permalink Normal View History

2022-04-22 13:05:56 +10: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 19:28:20 +10:00
return error({ statusCode: 204, pageName: 'governance' })
2022-04-22 13:05:56 +10:00
}
},
components: {
Metrics
},
computed: {
...mapState('metamask', ['isInitialized']),
...mapGetters('governance/gov', ['isEnabledGovernance'])
},
watch: {
isInitialized: {
handler() {
2022-05-27 19:28:20 +10:00
if (this.isEnabledGovernance) {
this.fetchProposals({})
this.fetchConstants()
}
2022-04-22 13:05:56 +10:00
},
immediate: true
},
isEnabledGovernance(isEnabled) {
if (!isEnabled) {
2022-05-27 19:28:20 +10:00
this.$nuxt.error({ statusCode: 204, pageName: 'governance' })
2022-04-22 13:05:56 +10:00
}
}
},
methods: {
...mapActions('governance/gov', ['fetchProposals', 'fetchConstants'])
}
}
</script>