From e3998c8eb22943ab022d337435846c594101c3bf Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sat, 15 Apr 2023 03:23:53 +0530 Subject: [PATCH] Bug fixes --- index.html | 59 +++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index 6623a26..e2d885a 100644 --- a/index.html +++ b/index.html @@ -388,25 +388,19 @@ // append latest transactions renderTransactions('contract_transaction_container', contractTransactions) - // console.log(contractParticipants) - // let winners = [] - // for (const participant in contractParticipants) { - // if (contractParticipants[participant].winningAmount) - // winners.push(contractParticipants[participant]) - // } - // for (const participant in contractParticipants) { - // console.log(contractParticipants[participant]) - // let { participantFloAddress, tokenIdentification, userChoice, tokenAmount } = contractParticipants[participant] - // if(userChoice) - // frag.append(render.contractChoiceCard(participantFloAddress, tokenIdentification, userChoice, tokenAmount)) - // } - // document.getElementById('participant_container').append(frag) + console.log(contractParticipants) + let winners = [] + for (const participant in contractParticipants) { + if (contractParticipants[participant].winningAmount) + winners.push(contractParticipants[participant]) + } + renderElem(document.getElementById('participant_container'), html`${ + Object.keys(contractParticipants).map(participant => render.contractChoiceCard(contractParticipants[participant])) + }`) - // winners.forEach(winner => { - // let { participantFloAddress, tokenIdentification, userChoice, tokenAmount, winningAmount } = winner; - // frag.append(render.contractChoiceCard(participantFloAddress, tokenIdentification, userChoice, tokenAmount, winningAmount)) - // }) - // document.getElementById('winners_container').append(frag) + if(winners.length){ + renderElem(document.getElementById('winners_container'), html`${winners.map(winner => render.contractChoiceCard(winner))}`) + } }) router.addRoute('block', async state => { @@ -802,7 +796,7 @@ ${userChoices ? html`

User Choices

@@ -913,31 +907,32 @@ Transactions Participants ${contractType === 'one-time-event' && contractSubtype === 'external-trigger' ? html`Winners` : ''} + ${contractType === 'continuos-event' && contractSubtype === 'token-swap' ? html`Deposits` : ''}
- ${contractType === 'one-time-event' && contractSubtype === 'external-trigger' ? html`` : ''} + ${contractType === 'one-time-event' && contractSubtype === 'external-trigger' ? html`` : ''} + ${contractType === 'continuos-event' && contractSubtype === 'token-swap' ? html`` : ''}
`; }, - contractChoiceCard(address, token, choice, amount, winningAmount) { - let card = document.createElement('li'), - action; - card.classList.add('contract-choice') + contractChoiceCard(details) { + const { participantFloAddress, userChoice, tokenAmount, transactionHash, winningAmount} = details; + let action; if (winningAmount) { action = 'Won' amount = winningAmount - } - else + }else action = 'Invested' - card.innerHTML = ` - ${address} -

${choice}

-

${formatAmount(amount, token.toLowerCase() === 'rupee' ? 'inr' : 'usd')} ${token} ${action}

- ` - return card; + return html` +
  • + ${participantFloAddress} +

    ${userChoice}

    +

    ${formatAmount(tokenAmount, 'usd')} ${action}

    +
  • + `; }, contractTransferCard(obj) { const { hash, token, sender, receiver, amount, contractName, userChoice, time } = obj;