From 81dc41652fab9e512f7281efdc5ae6fc30194772 Mon Sep 17 00:00:00 2001 From: Pham Tu Date: Sun, 21 Jan 2024 11:05:28 +0700 Subject: [PATCH] better format enum --- src/components/ProposalListItem.vue | 18 ++++++++++-------- src/modules/[chain]/cosmwasm/index.vue | 8 +++++++- src/modules/[chain]/gov/[proposal_id].vue | 18 ++++++++++-------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/components/ProposalListItem.vue b/src/components/ProposalListItem.vue index 028180d6..58b50ab5 100644 --- a/src/components/ProposalListItem.vue +++ b/src/components/ProposalListItem.vue @@ -136,10 +136,11 @@ function metaItem(metadata: string | undefined): { item?.voterStatus !== VoteOption.VOTE_OPTION_NO_WITH_VETO " >{{ - voteOptionToJSON(item?.voterStatus).replace( - 'VOTE_OPTION_', - '' - ) + voteOptionToJSON(item?.voterStatus) + .toLowerCase() + .replace(/^vote_option/, '') + .replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase()) + .trim() }} @@ -237,10 +238,11 @@ function metaItem(metadata: string | undefined): { {{ - voteOptionToJSON(item?.voterStatus).replace( - 'VOTE_OPTION_', - '' - ) + voteOptionToJSON(item?.voterStatus) + .toLowerCase() + .replace(/^vote_option/, '') + .replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase()) + .trim() }} diff --git a/src/modules/[chain]/cosmwasm/index.vue b/src/modules/[chain]/cosmwasm/index.vue index 37f9f602..05c2aed9 100644 --- a/src/modules/[chain]/cosmwasm/index.vue +++ b/src/modules/[chain]/cosmwasm/index.vue @@ -71,7 +71,13 @@ function myContracts() { {{ v.creator }} - {{ accessTypeToJSON(v.instantiatePermission?.permission) }} + {{ + accessTypeToJSON(v.instantiatePermission?.permission) + .toLowerCase() + .replace(/^access_type/, '') + .replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase()) + .trim() + }} {{ v.instantiatePermission?.address }} {{ v.instantiatePermission?.addresses.join(', ') }} { }); const status = computed(() => { if (proposal.value.status) { - return proposalStatusToJSON(proposal.value.status).replace( - 'PROPOSAL_STATUS_', - '' - ); + return proposalStatusToJSON(proposal.value.status) + .toLowerCase() + .replace(/^proposal_status/, '') + .replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase()) + .trim(); } return ''; }); @@ -440,10 +441,11 @@ function metaItem(metadata: string | undefined): { item.options .map( (x) => - `${voteOptionToJSON(x.option).replace( - 'VOTE_OPTION_', - '' - )}:${format.percent(x.weight)}` + `${voteOptionToJSON(x.option) + .toLowerCase() + .replace(/^vote_option/, '') + .replaceAll(/_(.)/g, (m, g) => ' ' + g.toUpperCase()) + .trim()}:${format.percent(x.weight)}` ) .join(', ') }}