SubmitCandidacy.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2017-2019 @polkadot/ui-staking 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 { ComponentProps } from './types';
  5. import BN from 'bn.js';
  6. import React from 'react';
  7. import { Button } from '@polkadot/react-components';
  8. import TxModal, { TxModalState as State, TxModalProps } from '@polkadot/react-components/TxModal';
  9. import translate from '../translate';
  10. interface Props extends ComponentProps, TxModalProps {}
  11. class SubmitCandidacy extends TxModal<Props, State> {
  12. protected headerText = (): string => this.props.t('Submit your council candidacy');
  13. protected accountLabel = (): string => this.props.t('Candidate account');
  14. protected accountHelp = (): string => this.props.t('This account will be nominated to fill the council slot you specify.');
  15. protected txMethod = (): string => 'elections.submitCandidacy';
  16. protected txParams = (): [BN] => {
  17. const { electionsInfo: { candidateCount } } = this.props;
  18. return [
  19. candidateCount
  20. ];
  21. }
  22. protected isDisabled = (): boolean => {
  23. const { accountId } = this.state;
  24. return !accountId;
  25. }
  26. protected renderTrigger = (): React.ReactNode => {
  27. const { t } = this.props;
  28. return (
  29. <Button
  30. isPrimary
  31. label={t('Submit candidacy')}
  32. icon='add'
  33. onClick={this.showModal}
  34. />
  35. );
  36. }
  37. }
  38. export default translate(SubmitCandidacy);