diff --git a/src/components/pricedButton/index.js b/src/components/pricedButton/index.js new file mode 100644 index 000000000..d70760127 --- /dev/null +++ b/src/components/pricedButton/index.js @@ -0,0 +1,32 @@ +import React from 'react'; +import Button from 'react-toolbox/lib/button'; +import { fromRawLsk } from '../../utils/lsk'; +import styles from './pricedButton.css'; + +const PricedButton = ({ + balance, fee, label, customClassName, onClick, disabled, +}) => { + const hasFunds = balance >= fee; + return ( +
+ { + fee && + ( + { + hasFunds ? `Fee: ${fromRawLsk(fee)} LSK` : + `Insufficient funds for ${fromRawLsk(fee)} LSK fee` + } + ) + } +
+ ); +}; + +export default PricedButton; diff --git a/src/components/pricedButton/index.test.js b/src/components/pricedButton/index.test.js new file mode 100644 index 000000000..add256e08 --- /dev/null +++ b/src/components/pricedButton/index.test.js @@ -0,0 +1,56 @@ +import React from 'react'; +import chai, { expect } from 'chai'; +import sinonChai from 'sinon-chai'; +import sinon from 'sinon'; +import { shallow } from 'enzyme'; +import chaiEnzyme from 'chai-enzyme'; +import Button from 'react-toolbox/lib/button'; +import PricedButton from './index'; + +chai.use(sinonChai); +chai.use(chaiEnzyme()); + +describe('PricedButton', () => { + let wrapper; + const props = { + fee: 5e8, + onClick: sinon.spy(), + }; + const insufficientBalance = 4.9999e8; + const sufficientBalance = 6e8; + + it('renders