VoteValue.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 { DerivedBalances } from '@polkadot/api-derive/types';
  5. import { I18nProps } from '@polkadot/react-components/types';
  6. import BN from 'bn.js';
  7. import React from 'react';
  8. import { InputBalance } from '@polkadot/react-components';
  9. import { BalanceVoting } from '@polkadot/react-query';
  10. import translate from '../translate';
  11. interface Props extends I18nProps {
  12. accountId?: string | null;
  13. allBalances?: DerivedBalances;
  14. onChange: (value: BN) => void;
  15. }
  16. const ZERO = new BN(0);
  17. function VoteValue ({ accountId, onChange, t }: Props): React.ReactElement<Props> {
  18. const _setVoteValue = (value?: BN): void => {
  19. onChange(value || ZERO);
  20. };
  21. return (
  22. <InputBalance
  23. help={t('The amount that is associated with this vote. This value is is locked for the duration of the vote.')}
  24. label={t('vote value')}
  25. labelExtra={<BalanceVoting label={t('voting balance ')} params={accountId} />}
  26. onChange={_setVoteValue}
  27. />
  28. );
  29. }
  30. export default translate(VoteValue);