classic-ui/pages/governance.vue

46 lines
1016 B
Vue
Raw Normal View History

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