ghost-portal/packages/ui-params/src/Param/Balance.tsx
Jaco Greeff 653c2a505f
Basic info display for 123-code (#641)
* Add withCalls

* withCalls operational

* Basic header display & cleanups

* Global account selector for app

* Remove errant debug log

* Simple transfer applet working

* Update Upgrade.tsx

* Update InputNumber.tsx

* Update Transfer.tsx

* Move TxButton back to 123code (for the time being)

* Good enough for a v1
2019-01-27 12:50:47 +01:00

57 lines
1.2 KiB
TypeScript

// Copyright 2017-2019 @polkadot/ui-app authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Props as BareProps } from '../types';
import BN from 'bn.js';
import React from 'react';
import { InputBalance } from '@polkadot/ui-app/index';
import Bare from './Bare';
type Props = BareProps;
class Balance extends React.PureComponent<Props> {
render () {
const { className, defaultValue: { value }, isDisabled, isError, label, style, withLabel } = this.props;
const defaultValue = new BN((value as BN || '0').toString()).toString(10);
return (
<Bare
className={className}
style={style}
>
<InputBalance
className='large'
defaultValue={defaultValue}
isDisabled={isDisabled}
isError={isError}
label={label}
onChange={this.onChange}
withLabel={withLabel}
/>
</Bare>
);
}
private onChange = (value?: BN): void => {
const { isError, onChange } = this.props;
if (!onChange) {
return;
}
onChange({
isValid: !isError && !!value,
value
});
}
}
export {
Balance
};
export default Balance;