Skip to content

Commit 1ed1403

Browse files
committed
voting fix
1 parent 3cc185b commit 1ed1403

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/components/tabs/subtabs/certificatesInTxPart.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import {iconCollapsed16, iconExpanded16} from '../../ui-constants'
44

55
const CertificatesInTxPart = ({getters}) => {
66
const {certsInTx, votesInTx} = getters
7-
const amountOfCertsAndVotesInTx = () => certsInTx.length + votesInTx.length
7+
let amountOfVotesInTx = 0
8+
if (votesInTx) {
9+
amountOfVotesInTx = JSON.parse(votesInTx).length
10+
}
11+
const amountOfCertsAndVotesInTx = () => certsInTx.length + amountOfVotesInTx
812
const getAllInOne = () => {
913
const resultArray = []
1014
for (const certInTx of certsInTx) {
@@ -13,11 +17,12 @@ const CertificatesInTxPart = ({getters}) => {
1317
const certJsonObject = JSON.parse(certInTx)
1418
resultArray.push([cleanCertName, certJsonObject])
1519
}
16-
for (const voteInTx of votesInTx) {
17-
const votePartWithName = voteInTx.split('\n')[1]
18-
const cleanVoteName = votePartWithName.split('"')[1]
19-
const voteJsonObject = JSON.parse(voteInTx)
20-
resultArray.push([cleanVoteName, voteJsonObject])
20+
if (votesInTx) {
21+
const voteJsonObjects = JSON.parse(votesInTx)
22+
console.log('voteJsonObjects', voteJsonObjects)
23+
for (const voteJsonObject of voteJsonObjects) {
24+
resultArray.push(['Votes', voteJsonObject])
25+
}
2126
}
2227
return resultArray
2328
}
@@ -28,7 +33,7 @@ const CertificatesInTxPart = ({getters}) => {
2833

2934
return (
3035
<ExpandablePanel
31-
title={`Certificates in Tx ( ${amountOfCertsAndVotesInTx()} )`}
36+
title={`Certificates and Votes in Tx ( ${amountOfCertsAndVotesInTx()} )`}
3237
generalPanelStyles={mainPanelStyles}
3338
titleStyles={mainPanelTitleStyles}
3439
collapsedIcon={iconCollapsed16}

src/components/tabs/subtabs/cip95AdditionalPart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import CertificatesInTxPart from './certificatesInTxPart'
99

1010
const Cip95AdditionalPart = ({api, onWaiting, onError, getters, setters}) => {
1111
const [certsInTx, setCertsInTx] = useState([])
12-
const [votesInTx, setVotesInTx] = useState([])
12+
const [votesInTx, setVotesInTx] = useState()
1313
const [certBuilder, setCertBuilder] = useState(null)
1414
const [votingBuilder, setVotingBuilder] = useState(null)
1515

0 commit comments

Comments
 (0)