Skip to content

Commit 568375d

Browse files
authored
Merge pull request #199 from forbole/feat/governance
added vote transaction
2 parents b29160c + 4c7fd26 commit 568375d

File tree

10 files changed

+100
-188
lines changed

10 files changed

+100
-188
lines changed

components/ProposalDetail/VoteTable.tsx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import {
1010
Card,
1111
Tabs,
1212
Tab,
13+
Link,
1314
} from '@material-ui/core'
1415
import useTranslation from 'next-translate/useTranslation'
1516
import React from 'react'
1617
import { useGetStyles } from './styles'
1718
import { VoteDetail } from './index'
1819
import { useGeneralContext } from '../../contexts/GeneralContext'
1920
import TablePagination from '../TablePagination'
20-
import { formatPercentage, formatCrypto } from '../../misc/utils'
21+
// import { formatPercentage, formatCrypto } from '../../misc/utils'
2122

2223
interface DepositTableProps {
2324
voteDetails: VoteDetail[]
@@ -46,18 +47,18 @@ const VoteTable: React.FC<DepositTableProps> = ({ voteDetails, crypto }) => {
4647
{
4748
label: 'voter',
4849
},
49-
{
50-
label: 'voting power',
51-
alignRight: true,
52-
},
53-
{
54-
label: 'voting power percentage',
55-
alignRight: true,
56-
},
57-
{
58-
label: 'voting power override',
59-
alignRight: true,
60-
},
50+
// {
51+
// label: 'voting power',
52+
// alignRight: true,
53+
// },
54+
// {
55+
// label: 'voting power percentage',
56+
// alignRight: true,
57+
// },
58+
// {
59+
// label: 'voting power override',
60+
// alignRight: true,
61+
// },
6162
{
6263
label: 'answer',
6364
alignRight: true,
@@ -98,16 +99,23 @@ const VoteTable: React.FC<DepositTableProps> = ({ voteDetails, crypto }) => {
9899
return (
99100
<TableRow className={classes.tableRow}>
100101
<TableCell className={classes.tableCell}>
101-
<Box className={classes.box} display="flex" alignItems="center">
102-
<Avatar
103-
className={classes.validatorAvatar}
104-
alt={v.voter.name}
105-
src={v.voter.image}
106-
/>
107-
<Typography className={classes.ellipsisText}>{v.voter.name}</Typography>
108-
</Box>
102+
<Link
103+
href={`${crypto.blockExplorerBaseUrl}/accounts/${v.voter.address}`}
104+
target="_blank"
105+
>
106+
<Box display="flex" alignItems="center">
107+
<Avatar
108+
className={classes.validatorAvatar}
109+
alt={v.voter.name}
110+
src={v.voter.image}
111+
/>
112+
<Typography className={classes.ellipsisText}>
113+
{v.voter.name || v.voter.address}
114+
</Typography>
115+
</Box>
116+
</Link>
109117
</TableCell>
110-
<TableCell align="right">
118+
{/* <TableCell align="right">
111119
<Typography variant="subtitle1">
112120
{formatCrypto(v.votingPower, crypto.name, lang)}
113121
</Typography>
@@ -121,7 +129,7 @@ const VoteTable: React.FC<DepositTableProps> = ({ voteDetails, crypto }) => {
121129
<Typography variant="subtitle1">
122130
{formatPercentage(v.votingPowerOverride, lang)}
123131
</Typography>
124-
</TableCell>
132+
</TableCell> */}
125133
<TableCell align="right" className={classes[v.answer]}>
126134
<Typography variant="subtitle1">{t(v.answer)}</Typography>
127135
</TableCell>

components/ProposalDetail/VoteTime.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const VoteTime: React.FC<ActiveProps> = ({ proposal }) => {
1313

1414
return (
1515
<Typography variant="subtitle1" color="textSecondary">
16-
{`${t('voting time')}: ${proposal.votingStartTime} to ${proposal.votingEndTime} `}
16+
{t('voting time', { from: proposal.votingStartTime, to: proposal.votingEndTime })}
1717
<span className={classes.duration}>
1818
{`(${proposal.duration} ${proposal.duration > 1 ? t('days') : t('day')})`}
1919
</span>

components/ProposalDetail/index.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ export interface VoteDetail {
2626
voter: {
2727
name: string
2828
image: string
29+
address: string
2930
}
30-
votingPower: number
31-
votingPowerPercentage: number
32-
votingPowerOverride: number
31+
// votingPower: number
32+
// votingPowerPercentage: number
33+
// votingPowerOverride: number
3334
answer: string
3435
}
3536

@@ -132,17 +133,13 @@ const ProposalDetail: React.FC<ProposalDetailProps> = ({
132133
) : null}
133134
</Box>
134135
</Card>
135-
{!proposal.isActive ? (
136-
<Card className={classes.card}>
137-
<Box m={4}>
138-
<VoteResult voteSummary={voteSummary} crypto={crypto} />
139-
<VoteTable voteDetails={voteDetails} crypto={crypto} />
140-
</Box>
141-
</Card>
142-
) : null}
143-
{proposal.tag !== 'vote' ? (
144-
<DepositTable network={network} proposal={proposal} crypto={crypto} tag={proposal.tag} />
145-
) : null}
136+
<Card className={classes.card}>
137+
<Box m={4}>
138+
<VoteResult voteSummary={voteSummary} crypto={crypto} />
139+
<VoteTable voteDetails={voteDetails} crypto={crypto} />
140+
</Box>
141+
</Card>
142+
<DepositTable network={network} proposal={proposal} crypto={crypto} tag={proposal.tag} />
146143
<VoteDialog
147144
proposal={proposal}
148145
network={network}

components/ProposalTable/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const ProposalTable: React.FC<ProposalsTableProps> = ({ proposals, network }) =>
5959
alt={x.proposer.name}
6060
src={x.proposer.image}
6161
/>
62-
<Typography variant="h6" className={classes.ellipsisText}>
62+
<Typography color="primary" variant="h6" className={classes.ellipsisText}>
6363
{x.proposer.name || x.proposer.address}
6464
</Typography>
6565
</Box>
@@ -70,7 +70,12 @@ const ProposalTable: React.FC<ProposalsTableProps> = ({ proposals, network }) =>
7070
{x.description}
7171
</Typography>
7272
<Typography variant="subtitle1" color="textSecondary">
73-
{`${t('voting time')}: ${x.votingStartTime} to ${x.votingEndTime}`}
73+
{x.tag === 'deposit'
74+
? t('deposit time', { from: x.submitTime, to: x.depositEndTime })
75+
: null}
76+
{x.tag === 'vote' || x.tag === 'passed'
77+
? t('voting time', { from: x.votingStartTime, to: x.votingEndTime })
78+
: null}
7479
{x.isActive ? (
7580
<span className={classes.duration}>
7681
{`(${t('in')} ${x.duration} ${x.duration > 1 ? t('days') : t('day')})`}

components/VoteDialog/SelectAnswer.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import {
22
Box,
33
Button,
4+
CircularProgress,
45
DialogContent,
56
InputAdornment,
67
TextField,
78
Typography,
9+
useTheme,
810
} from '@material-ui/core'
911
import { Autocomplete } from '@material-ui/lab'
1012
import useTranslation from 'next-translate/useTranslation'
@@ -19,29 +21,31 @@ interface SelectAnswerProps {
1921
network: Chain
2022
onNext(voteAccount: Account, answer: { name: string; id: string }, memo?: string): void
2123
proposal: Proposal
24+
loading: boolean
2225
}
2326

24-
const SelectAnswer: React.FC<SelectAnswerProps> = ({ network, onNext, proposal }) => {
27+
const SelectAnswer: React.FC<SelectAnswerProps> = ({ network, onNext, proposal, loading }) => {
2528
const { t } = useTranslation('common')
2629
const classes = useStyles()
2730
const { accounts: allAccounts } = useWalletsContext()
31+
const theme = useTheme()
2832
const accounts = allAccounts.filter((a) => a.crypto === network.crypto)
2933
const answers = [
3034
{
3135
name: 'Yes',
32-
id: '01',
36+
id: '1',
3337
},
3438
{
3539
name: 'No',
36-
id: '02',
40+
id: '2',
3741
},
3842
{
3943
name: 'Veto',
40-
id: '03',
44+
id: '3',
4145
},
4246
{
4347
name: 'Abstain',
44-
id: '04',
48+
id: '4',
4549
},
4650
]
4751

@@ -180,10 +184,10 @@ const SelectAnswer: React.FC<SelectAnswerProps> = ({ network, onNext, proposal }
180184
variant="contained"
181185
className={classes.button}
182186
color="primary"
183-
disabled={!!(answer === undefined)}
187+
disabled={loading || answer === undefined}
184188
type="submit"
185189
>
186-
{t('next')}
190+
{loading ? <CircularProgress size={theme.spacing(3.5)} /> : t('next')}
187191
</Button>
188192
</Box>
189193
</Box>

0 commit comments

Comments
 (0)