classic-ui/pages/governance.vue

44 lines
899 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']) {
return error({ statusCode: 404 })
}
},
components: {
Metrics
},
computed: {
...mapState('metamask', ['isInitialized']),
...mapGetters('governance/gov', ['isEnabledGovernance'])
},
watch: {
isInitialized: {
handler() {
this.fetchProposals({})
this.fetchConstants()
},
immediate: true
},
isEnabledGovernance(isEnabled) {
if (!isEnabled) {
this.$router.push('/')
}
}
},
methods: {
...mapActions('governance/gov', ['fetchProposals', 'fetchConstants'])
}
}
</script>