Split council num votes (#3270)

* Split council num votes

* Reformat candidates
This commit is contained in:
Jaco Greeff 2020-07-26 16:34:57 +02:00 committed by GitHub
parent d78b1f928c
commit f9290a007f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 26 deletions

View File

@ -35,12 +35,10 @@ function Candidate ({ address, balance, className = '', isPrime, voters }: Props
/>
)}
</td>
<td className='all number'>
<Voters
balance={balance}
voters={voters}
/>
</td>
<Voters
balance={balance}
voters={voters}
/>
</tr>
);
}

View File

@ -22,12 +22,14 @@ function Candidates ({ allVotes = {}, electionsInfo }: Props): React.ReactElemen
const headerCandidates = useMemo(() => [
[t('candidates'), 'start', 2],
[],
[]
], [t]);
const headerRunners = useMemo(() => [
[t('runners up'), 'start', 2],
[t('backing')]
[t('backing')],
[t('votes')]
], [t]);
return (

View File

@ -23,7 +23,8 @@ function Members ({ allVotes = {}, className = '', electionsInfo, prime }: Props
const header = useMemo(() => [
[t('members'), 'start', 2],
[t('backing')]
[t('backing')],
[t('votes')]
], [t]);
return (

View File

@ -7,34 +7,35 @@ import { AccountId, Balance } from '@polkadot/types/interfaces';
import React from 'react';
import { AddressMini, Expander } from '@polkadot/react-components';
import { FormatBalance } from '@polkadot/react-query';
import { formatNumber } from '@polkadot/util';
interface Props {
balance?: Balance;
voters?: AccountId[];
}
function Voters ({ balance, voters }: Props): React.ReactElement<Props> | null {
function Voters ({ balance, voters }: Props): React.ReactElement<Props> {
if (!balance || !voters || !voters.length) {
return null;
return <><td className='all number' /><td className='number' /></>;
}
return (
<Expander
summary={
<FormatBalance
labelPost={` (${voters.length})`}
value={balance}
/>
}
>
{voters.map((who): React.ReactNode =>
<AddressMini
key={who.toString()}
value={who}
withLockedVote
/>
)}
</Expander>
<>
<td className='all number'>
<Expander summary={<FormatBalance value={balance} />} >
{voters.map((who): React.ReactNode =>
<AddressMini
key={who.toString()}
value={who}
withLockedVote
/>
)}
</Expander>
</td>
<td className='number'>
{formatNumber(voters.length)}
</td>
</>
);
}