Applicant.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from 'react';
  2. import { Link } from 'react-router-dom';
  3. import { Table } from 'semantic-ui-react';
  4. import { I18nProps } from '@polkadot/react-components/types';
  5. import { ApiProps } from '@polkadot/react-api/types';
  6. import { withCalls } from '@polkadot/react-api/with';
  7. import { AccountId } from '@polkadot/types/interfaces';
  8. import { formatBalance } from '@polkadot/util';
  9. import CandidatePreview from './CandidatePreview';
  10. import translate from './translate';
  11. import { calcTotalStake } from '@polkadot/joy-utils/index';
  12. import { ElectionStake } from '@joystream/types/council';
  13. type Props = ApiProps & I18nProps & {
  14. index: number;
  15. accountId: AccountId;
  16. stake?: ElectionStake;
  17. };
  18. class Applicant extends React.PureComponent<Props> {
  19. render () {
  20. const { index, accountId, stake } = this.props;
  21. const voteUrl = `/council/votes?applicantId=${accountId.toString()}`;
  22. return (
  23. <Table.Row>
  24. <Table.Cell>{index + 1}</Table.Cell>
  25. <Table.Cell>
  26. <CandidatePreview accountId={accountId}/>
  27. </Table.Cell>
  28. <Table.Cell style={{ textAlign: 'right' }}>
  29. {formatBalance(calcTotalStake(stake))}
  30. </Table.Cell>
  31. <Table.Cell>
  32. <Link to={voteUrl} className='ui button primary inverted'>Vote</Link>
  33. </Table.Cell>
  34. </Table.Row>
  35. );
  36. }
  37. }
  38. // inject the actual API calls automatically into props
  39. export default translate(
  40. withCalls<Props>(
  41. ['query.councilElection.applicantStakes',
  42. { paramName: 'accountId', propName: 'stake' }]
  43. )(Applicant)
  44. );