|
@@ -9,15 +9,13 @@ import { I18nProps } from '@polkadot/react-components/types';
|
|
|
import BN from 'bn.js';
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
import styled from 'styled-components';
|
|
|
-import { ActionItem, Chart, Static, Voting } from '@polkadot/react-components';
|
|
|
-import { formatBalance, formatNumber } from '@polkadot/util';
|
|
|
-import VoteThreshold from '@polkadot/react-params/Param/VoteThreshold';
|
|
|
+import { formatNumber } from '@polkadot/util';
|
|
|
import { withCalls, withMulti } from '@polkadot/react-api';
|
|
|
+import { FormatBalance } from '@polkadot/react-query';
|
|
|
|
|
|
import translate from '../translate';
|
|
|
-
|
|
|
-const COLORS_AYE = ['#64bebe', '#5badad'];
|
|
|
-const COLORS_NAY = ['#d75ea1', '#e189ba'];
|
|
|
+import ProposalCell from './ProposalCell';
|
|
|
+import Voting from './Voting';
|
|
|
|
|
|
interface Props extends I18nProps {
|
|
|
idNumber: BN;
|
|
@@ -37,7 +35,7 @@ interface State {
|
|
|
}
|
|
|
|
|
|
function Referendum ({ chain_bestNumber, className, democracy_enactmentPeriod, democracy_referendumVotesFor, t, value }: Props): React.ReactElement<Props> | null {
|
|
|
- const [{ voteCount, voteCountAye, voteCountNay, votedAye, votedNay, votedTotal }, setState] = useState<State>({
|
|
|
+ const [{ voteCountAye, voteCountNay, votedAye, votedNay }, setState] = useState<State>({
|
|
|
voteCount: 0,
|
|
|
voteCountAye: 0,
|
|
|
voteCountNay: 0,
|
|
@@ -85,63 +83,29 @@ function Referendum ({ chain_bestNumber, className, democracy_enactmentPeriod, d
|
|
|
const enactBlock = (democracy_enactmentPeriod || new BN(0)).add(value.info.end);
|
|
|
|
|
|
return (
|
|
|
- <ActionItem
|
|
|
- className={className}
|
|
|
- idNumber={value.index}
|
|
|
- proposal={value.proposal}
|
|
|
- accessory={
|
|
|
- <Voting
|
|
|
- idNumber={value.index}
|
|
|
- proposal={value.proposal}
|
|
|
- />
|
|
|
- }
|
|
|
- >
|
|
|
- <div>
|
|
|
- <Static label={t('ending at')}>
|
|
|
- {t('block #{{blockNumber}}, {{remaining}} blocks remaining', {
|
|
|
- replace: {
|
|
|
- blockNumber: formatNumber(value.info.end),
|
|
|
- remaining: formatNumber(value.info.end.sub(chain_bestNumber).subn(1))
|
|
|
- }
|
|
|
- })}
|
|
|
- </Static>
|
|
|
- <Static label={t('activate at (if passed)')}>
|
|
|
- {t('block #{{blockNumber}}', {
|
|
|
- replace: {
|
|
|
- blockNumber: formatNumber(enactBlock)
|
|
|
- }
|
|
|
- })}
|
|
|
- </Static>
|
|
|
- <VoteThreshold
|
|
|
- isDisabled
|
|
|
- defaultValue={{ isValid: true, value: value.info.threshold }}
|
|
|
- label={t('vote threshold')}
|
|
|
- name='voteThreshold'
|
|
|
- type={{
|
|
|
- info: 0,
|
|
|
- type: 'VoteThreshold'
|
|
|
- }}
|
|
|
- />
|
|
|
- {voteCount !== 0 && votedTotal.gtn(0) && (
|
|
|
- <div className='democracy--Referendum-results chart'>
|
|
|
- <Chart.HorizBar
|
|
|
- values={[
|
|
|
- {
|
|
|
- colors: COLORS_AYE,
|
|
|
- label: `Aye, ${formatBalance(votedAye, { forceUnit: '-' })} (${formatNumber(voteCountAye)})`,
|
|
|
- value: votedAye.muln(10000).div(votedTotal).toNumber() / 100
|
|
|
- },
|
|
|
- {
|
|
|
- colors: COLORS_NAY,
|
|
|
- label: `Nay, ${formatBalance(votedNay, { forceUnit: '-' })} (${formatNumber(voteCountNay)})`,
|
|
|
- value: votedNay.muln(10000).div(votedTotal).toNumber() / 100
|
|
|
- }
|
|
|
- ]}
|
|
|
- />
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- </ActionItem>
|
|
|
+ <tr className={className}>
|
|
|
+ <td className='number toppad'>{formatNumber(value.index)}</td>
|
|
|
+ <ProposalCell className='top' proposal={value.proposal} />
|
|
|
+ <td className='number together top'>
|
|
|
+ <label>{t('remaining')}</label>
|
|
|
+ {formatNumber(value.info.end.sub(chain_bestNumber).subn(1))} blocks
|
|
|
+ </td>
|
|
|
+ <td className='number together top'>
|
|
|
+ <label>{t('activate at')}</label>
|
|
|
+ {formatNumber(enactBlock)}
|
|
|
+ </td>
|
|
|
+ <td className='number together top'>
|
|
|
+ <label>{t('Aye ({{count}})', { replace: { count: formatNumber(voteCountAye) } })}</label>
|
|
|
+ <FormatBalance value={votedAye} />
|
|
|
+ </td>
|
|
|
+ <td className='number together top'>
|
|
|
+ <label>{t('Nay ({{count}})', { replace: { count: formatNumber(voteCountNay) } })}</label>
|
|
|
+ <FormatBalance value={votedNay} />
|
|
|
+ </td>
|
|
|
+ <td className='number together top'>
|
|
|
+ <Voting referendumId={value.index} />
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
);
|
|
|
}
|
|
|
|