This commit is contained in:
liangping
2023-04-07 10:11:48 +08:00
parent 8c31935432
commit d3a7c6f176
14 changed files with 142 additions and 68 deletions
+37
View File
@@ -0,0 +1,37 @@
<script lang="ts" setup>
import { useGovStore } from '@/stores';
import ProposalListItem from '@/components/ProposalListItem.vue';
const tab = ref("")
const store = useGovStore()
store.fetchProposals("2")
</script>
<template>
<div>
<VTabs v-model="tab">
<VTab value="2">Voting</VTab>
<VTab value="3" @click="store.fetchProposals('3')">Passed</VTab>
<VTab value="4" @click="store.fetchProposals('4')">Rejected</VTab>
</VTabs>
<VWindow v-model="tab" class="mt-5">
<VWindowItem value="2">
<ProposalListItem :proposals="store.proposals['2']"/>
</VWindowItem>
<VWindowItem value="3">
<ProposalListItem :proposals="store.proposals['3']"/>
</VWindowItem>
<VWindowItem value="4">
<ProposalListItem :proposals="store.proposals['4']"/>
</VWindowItem>
</VWindow>
</div>
</template>
<route>
{
meta: {
i18n: 'governance'
}
}
</route>
+2 -32
View File
@@ -8,7 +8,7 @@ import { useIndexModule } from './indexStore';
import { computed } from '@vue/reactivity';
import CardStatisticsVertical from '@/components/CardStatisticsVertical.vue';
import ProposalProcess from '@/components/ProposalProcess.vue';
import ProposalListItem from '@/components/ProposalListItem.vue';
const blockchain = useBlockchain()
const store = useIndexModule()
@@ -143,37 +143,7 @@ function shortName(name: string, id: string) {
<VCardTitle>Active Proposals</VCardTitle>
</VCardItem>
<VCardItem>
<VExpansionPanels variant="accordion">
<VExpansionPanel v-for="(x, i) in store.proposals">
<VExpansionPanelTitle disable-icon-rotate>
<VChip label color="primary" class="mr-2">{{x.proposal_id}}</VChip>
<div class="w-100">{{ x.content?.title }}
<div class="d-flex mt-1">
<small class="text-secondary me-auto"> {{ format.toDay(x.voting_end_time, 'from') }}</small>
<ProposalProcess style="width:300px;" :pool="store.pool" :tally="store.tally[x.proposal_id]"></ProposalProcess>
<span></span>
</div>
</div>
<template #actions>
<VIcon
icon="mdi-check"
color="success"
class="ml-2"
/>
</template>
</VExpansionPanelTitle>
<VExpansionPanelText>
<VCard class="card-box">
<VCardText>
<MdEditor :model-value="x.content?.description" previewOnly></MdEditor>
</VCardText>
<div class="text-center w-100 my-2">
<VBtn color="primary" variant="flat">Vote</VBtn>
</div>
</VCard>
</VExpansionPanelText>
</VExpansionPanel>
</VExpansionPanels>
<ProposalListItem :proposals="store.proposals"/>
</VCardItem>
<VCardText v-if="store.proposals.length === 0">No active proposals</VCardText>
</VCard>
+4 -10
View File
@@ -2,7 +2,7 @@ import { useBlockchain, useCoingecko, useBaseStore, useBankStore, useFormatter,
import { useDistributionStore } from "@/stores/useDistributionStore";
import { useMintStore } from "@/stores/useMintStore";
import { useStakingStore } from "@/stores/useStakingStore";
import type { GovProposal, Tally } from "@/types";
import type { GovProposal, PaginatedProposals, Tally } from "@/types";
import numeral from "numeral";
import { defineStore } from "pinia";
@@ -65,7 +65,7 @@ export const useIndexModule = defineStore('module-index', {
total_volumes: [] as number[],
},
communityPool: [] as {amount: string, denom: string}[],
proposals: [] as GovProposal[],
proposals: {} as PaginatedProposals,
tally: {} as Record<string, Tally>
}
},
@@ -187,14 +187,8 @@ export const useIndexModule = defineStore('module-index', {
}))
})
const gov = useGovStore()
gov.fetchProposals(2).then(x => {
this.proposals = x.proposals
x.proposals.forEach(x1 => {
gov.fetchTally(x1.proposal_id).then(t => {
console.log("log: ", t)
if(t.tally) this.tally[x1.proposal_id] = t.tally
})
})
gov.fetchProposals("2").then(x => {
this.proposals = x
})
},
tickerColor(color: string) {
-3
View File
@@ -1,3 +0,0 @@
<template>
<div>Hello module</div>
</template>
+1 -1
View File
@@ -48,7 +48,7 @@ const messages = computed(() => {
<div><DynamicComponent :value="msg" /></div>
</div>
<div v-if="messages.length === 0">
<VIcon icon="mdi-empty"/>
No messages
</div>
</VCardItem>
</VCard>