index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2017-2019 @polkadot/app-democracy authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import { DerivedElectionsInfo } from '@polkadot/api-derive/types';
  5. import { BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
  6. import { ComponentProps as Props } from './types';
  7. import BN from 'bn.js';
  8. import React from 'react';
  9. import { withCalls } from '@polkadot/react-api';
  10. import { Button } from '@polkadot/react-components';
  11. import Members from './Members';
  12. import SubmitCandidacy from './SubmitCandidacy';
  13. import Summary from './Summary';
  14. import Vote from './Vote';
  15. const NULL_INFO: DerivedElectionsInfo = {
  16. members: {},
  17. candidates: [],
  18. candidateCount: new BN(0),
  19. desiredSeats: new BN(0),
  20. nextVoterSet: new BN(0) as SetIndex,
  21. termDuration: new BN(0) as BlockNumber,
  22. voteCount: new BN(0) as VoteIndex,
  23. voterCount: new BN(0) as SetIndex
  24. };
  25. class Overview extends React.PureComponent<Props> {
  26. public render (): React.ReactNode {
  27. const { electionsInfo = NULL_INFO } = this.props;
  28. return (
  29. <>
  30. <Summary electionsInfo={electionsInfo} />
  31. <Button.Group>
  32. <SubmitCandidacy electionsInfo={electionsInfo} />
  33. <Button.Or />
  34. <Vote electionsInfo={electionsInfo} />
  35. </Button.Group>
  36. <Members electionsInfo={electionsInfo} />
  37. </>
  38. );
  39. }
  40. }
  41. export default withCalls<Props>(
  42. [
  43. 'derive.elections.info',
  44. {
  45. propName: 'electionsInfo'
  46. }
  47. ]
  48. )(Overview);