classic-ui/pages/governance/_id.vue

56 lines
1.4 KiB
Vue
Raw Permalink Normal View History

2022-04-22 06:05:56 +03:00
<template>
<div>
<b-button type="is-back" icon-left="arrow-left" @click="onBack">
{{ $t('back') }}
</b-button>
<ProposalSkeleton v-if="isFetchingProposals" />
<Proposal v-else-if="proposal" :data="proposal" />
<div v-else>{{ $t('proposalDoesNotExist') }}</div>
</div>
</template>
<script>
import { mapState, mapActions, mapGetters } from 'vuex'
import Proposal from '@/components/governance/Proposal'
import ProposalSkeleton from '@/components/governance/ProposalSkeleton'
export default {
components: {
Proposal,
ProposalSkeleton
},
computed: {
...mapState('governance/gov', ['proposals']),
2022-05-27 12:28:20 +03:00
...mapGetters('governance/gov', ['isFetchingProposals', 'isEnabledGovernance']),
2022-04-22 06:05:56 +03:00
...mapState('metamask', ['isInitialized']),
proposal() {
return this.proposals[this.$route.params.id - 1]
}
},
watch: {
isInitialized: {
handler(isInitialized) {
2022-05-27 12:28:20 +03:00
if (isInitialized && this.isEnabledGovernance) {
2022-04-22 06:05:56 +03:00
this.fetchBalances()
this.fetchedLockedTimestamp()
this.fetchDelegatee()
this.fetchLatestProposalId()
}
},
immediate: true
}
},
methods: {
...mapActions('governance/gov', [
'fetchBalances',
'fetchedLockedTimestamp',
'fetchDelegatee',
'fetchLatestProposalId'
]),
onBack() {
this.$router.push({ path: '/governance' })
}
}
}
</script>