Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Commit

Permalink
changes:
Browse files Browse the repository at this point in the history
  - show the alert as already voted if hasVoted
  - else show the button for casting vote in case of active sate proposal

#424
  • Loading branch information
sk-enya committed Sep 12, 2021
1 parent cecb468 commit 2b43568
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 59 deletions.
109 changes: 53 additions & 56 deletions packages/omgx/wallet-frontend/src/components/Proposal/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ function Proposal({

<div
onClick={() => {
if(proposal.state !== 'Active') {
return;
}
setDropDownBox(!dropDownBox)
setDropDownBoxInit(false)
}}
Expand All @@ -90,18 +93,6 @@ function Proposal({
<Typography variant="body3" component="p" className={styles.muted}>Title: <FormatDescription description={proposal.description} /></Typography>
<Typography variant="body3" component="p" className={styles.muted}>Status: {proposal.state}</Typography>
<Typography variant="body3" component="p" className={styles.muted}>Start L1 Block: {proposal.startBlock} &nbsp; &nbsp; End L1 Block: {proposal.endBlock}</Typography>
{proposal.state === 'Active' &&
<div style={{
background: 'blue',
borderRadius: '8px',
width: '100px',
height: '25px',
fontSize: '0.9em',
display: 'flex',
flexDirection: 'row',
justifyContent: 'center'
}}>VOTE</div>
}
</div>
<div>
<Typography variant="body3" component="p" className={styles.vote}>For: {proposal.forVotes}</Typography>
Expand All @@ -114,50 +105,56 @@ function Proposal({
</div>

<div className={dropDownBox ? styles.dropDownContainer : dropDownBoxInit ? styles.dropDownInit : styles.closeDropDown}>
<div className={styles.proposalDetail}>
<Typography variant="body2">Note: only your first vote counts.</Typography>
<Button
type="primary"
variant="outlined"
style={{
maxWidth: '180px',
padding: '15px 10px',
borderRadius: '8px',
alignSelf: 'center'
}}
onClick={(e) => {
updateVote(proposal.id, 1, 'Cast Vote For')
}}

> Cast Vote For</Button>
<Button
type="primary"
variant="outlined"
style={{
maxWidth: '180px',
padding: '15px 10px',
borderRadius: '8px',
alignSelf: 'center'
}}
onClick={(e) => {
updateVote(proposal.id, 0, 'Cast Vote Against')
}}

> Cast Vote Against</Button>
<Button
type="outline"
variant="outlined"
style={{
maxWidth: '180px',
padding: '15px 10px',
borderRadius: '8px',
alignSelf: 'center'
}}
onClick={(e) => {
updateVote(proposal.id, 2, 'Cast Vote Abstain')
}}
> Cast Vote Abstain</Button>
</div>
{
proposal.hasVoted ?
<div className={styles.proposalDetail}>
<Typography variant="body2">Thank you for voting - your vote has been recorded</Typography>
</div>
: <div className={styles.proposalDetail}>
<Typography variant="body2">Note: only your first vote counts.</Typography>
<Button
type="primary"
variant="outlined"
style={{
maxWidth: '180px',
padding: '15px 10px',
borderRadius: '8px',
alignSelf: 'center'
}}
onClick={(e) => {
updateVote(proposal.id, 1, 'Cast Vote For')
}}

> Cast Vote For</Button>
<Button
type="primary"
variant="outlined"
style={{
maxWidth: '180px',
padding: '15px 10px',
borderRadius: '8px',
alignSelf: 'center'
}}
onClick={(e) => {
updateVote(proposal.id, 0, 'Cast Vote Against')
}}

> Cast Vote Against</Button>
<Button
type="outline"
variant="outlined"
style={{
maxWidth: '180px',
padding: '15px 10px',
borderRadius: '8px',
alignSelf: 'center'
}}
onClick={(e) => {
updateVote(proposal.id, 2, 'Cast Vote Abstain')
}}
> Cast Vote Abstain</Button>
</div>
}
</div>
</div>)
}
Expand Down
8 changes: 5 additions & 3 deletions packages/omgx/wallet-frontend/src/services/networkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@ class NetworkService {
if(this.masterSystemConfig !== 'rinkeby' || this.L1orL2 !== 'L2') return

const delegateCheck = await this.delegate.attach(this.delegator.address)

try {
let proposalList = [];
const proposalCounts = await delegateCheck.proposalCount()
Expand Down Expand Up @@ -2160,6 +2160,8 @@ class NetworkService {

let proposal = await delegateCheck.getActions(i+2)

const {hasVoted} = await delegateCheck.getReceipt(proposalID, delegateCheck.address);

let description = descriptionList[i].args[8].toString()

proposalList.push({
Expand All @@ -2172,8 +2174,8 @@ class NetworkService {
abstainVotes,
state: proposalStates[state],
startBlock,
endBlock

endBlock,
hasVoted
})

}
Expand Down

0 comments on commit 2b43568

Please sign in to comment.