import React from 'react'; import { ApiProps } from '@polkadot/react-api/types'; import { I18nProps } from '@polkadot/react-components/types'; import { withCalls } from '@polkadot/react-api/with'; import { Table } from 'semantic-ui-react'; import { formatBalance } from '@polkadot/util'; import CouncilCandidate from './CandidatePreview'; import { calcBackersStake } from '@polkadot/joy-utils/index'; import { Seat } from '@joystream/types/'; import translate from './translate'; import Section from '@polkadot/joy-utils/Section'; type Props = ApiProps & I18nProps & { council?: Seat[]; }; type State = {}; class Council extends React.PureComponent { state: State = {}; private renderTable (council: Seat[]) { return ( # Council member Own stake {'Backers\' stake'} Backers count {council.map((seat, index) => ( {index + 1} {formatBalance(seat.stake)} {formatBalance(calcBackersStake(seat.backers))} {seat.backers.length} ))}
); } render () { const { council = [] } = this.props; // console.log({ council }); return (
{!council.length ? Council is not elected yet : this.renderTable(council)}
); } } // inject the actual API calls automatically into props export default translate( withCalls(['query.council.activeCouncil', { propName: 'council' }])(Council) );