From 581a3b0e3375611d95a4832b4e95a2b567b01171 Mon Sep 17 00:00:00 2001 From: alisa Date: Tue, 25 Apr 2023 00:37:16 +0800 Subject: [PATCH] feature: governance list --- src/components/ProposalListItem.vue | 99 ++++++++++++------------ src/components/ProposalProcess.vue | 58 +++++--------- src/layouts/components/DefaultLayout.vue | 60 +++++++------- tailwind.config.js | 8 +- 4 files changed, 109 insertions(+), 116 deletions(-) diff --git a/src/components/ProposalListItem.vue b/src/components/ProposalListItem.vue index cef0985c..edfa7c0f 100644 --- a/src/components/ProposalListItem.vue +++ b/src/components/ProposalListItem.vue @@ -6,57 +6,56 @@ import ProposalProcess from './ProposalProcess.vue'; import type { PropType } from 'vue'; const props = defineProps({ - proposals: { type: Object as PropType}, -}) + proposals: { type: Object as PropType }, +}); // const list = computed(()=> proposl) -const format = useFormatter() -const staking = useStakingStore() -const chain = useBlockchain() -function showType(v: string){ - if(v) { - return v.substring(v.lastIndexOf('.')+1) - } - return v +const format = useFormatter(); +const staking = useStakingStore(); +const chain = useBlockchain(); +function showType(v: string) { + if (v) { + return v.substring(v.lastIndexOf('.') + 1); + } + return v; } + +const statusMap: Record = { + PROPOSAL_STATUS_VOTING_PERIOD: 'VOTING', + PROPOSAL_STATUS_PASSED: 'PASSED', + PROPOSAL_STATUS_REJECTED: 'REJECTED', +}; \ No newline at end of file +
+ +
+
#{{ item?.proposal_id }}
+ +
+ {{ item?.content?.title }} +
+ +
+
+ {{ showType(item.content['@type']) }} +
+
+ +
+
+
{{ statusMap?.[item?.status] || item?.status }}
+
+ +
+ {{ format.toDay(item.voting_end_time, 'from') }} +
+
+ +
+
+ diff --git a/src/components/ProposalProcess.vue b/src/components/ProposalProcess.vue index 82fd26e2..ab6db423 100644 --- a/src/components/ProposalProcess.vue +++ b/src/components/ProposalProcess.vue @@ -2,52 +2,36 @@ import { useFormatter } from '@/stores'; import type { Tally } from '@/types'; import { computed } from '@vue/reactivity'; -import { ref, type PropType } from 'vue'; - +import type { PropType } from 'vue'; const props = defineProps({ - tally: { type: Object as PropType}, + tally: { type: Object as PropType }, pool: { type: Object as PropType<{ - not_bonded_tokens: string; - bonded_tokens: string; + not_bonded_tokens: string; + bonded_tokens: string; }>, }, -}) -const total = computed(() => props.pool?.bonded_tokens) -const format = useFormatter() -const yes = computed(() => (format.calculatePercent(props.tally?.yes, total.value))) -const no = computed(() => ref(format.calculatePercent(props.tally?.no, total.value))) -const abstain = computed(() => (format.calculatePercent(props.tally?.abstain, total.value))) -const veto = computed(() => (format.calculatePercent(props.tally?.no_with_veto, total.value))) - +}); +const total = computed(() => props.pool?.bonded_tokens); +const format = useFormatter(); +const yes = computed(() => format.calculatePercent(props.tally?.yes, total.value)); +const no = computed(() => format.calculatePercent(props.tally?.no, total.value)); +const abstain = computed(() => format.calculatePercent(props.tally?.abstain, total.value)); +const veto = computed(() => format.calculatePercent(props.tally?.no_with_veto, total.value)); + \ No newline at end of file + diff --git a/src/layouts/components/DefaultLayout.vue b/src/layouts/components/DefaultLayout.vue index b4373bf3..309525fc 100644 --- a/src/layouts/components/DefaultLayout.vue +++ b/src/layouts/components/DefaultLayout.vue @@ -1,41 +1,42 @@