MyCrypto/common/containers/Tabs/Swap/components/ReceivingAddress.jsx
William O'Beirne de7d4fbaa2 v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less

* Darken body, adjust header.

* First pass at tab styles, each tab will need a lot of individual love tho.

* Update footer to main site content, improve responsiveness.

* Missing key added.

* Fix dropdowns.

* Convert GenerateWallet HTML over, still needs styling.

* Send form.

* Current rates styled.

* CurrencySwap form styles.

* SwapInfoHeader styled.

* Finish up swap restyling, minor usability improvements for mobile.

* Fix up notifications / alert customizations

* Import v3 variables.

* Fix notification spacing.

* Align input height base with buttons.

* Revert height base, add additional bootstrap overrides.

* Grid overrides.

* Move overrides to their own folder. Adjust naming.

* Fix inconsistencies.

* Style generate wallet pt 1.

* Style generate wallet pt 2

* Style generate wallet pt 3

* Fix swap

* Added some missing overries, fixed the fallout.

* Remove header text, indicate alpha version.

* Fix radio / checkbox weights.

* Bind => arrow

* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.

* Fix token balances buttons, footr icons.
2017-09-05 14:52:01 -05:00

102 lines
3.1 KiB
JavaScript

// @flow
import './ReceivingAddress.scss';
import React, { Component } from 'react';
import classnames from 'classnames';
import type {
DestinationAddressSwapAction,
ChangeStepSwapAction,
StopLoadBityRatesSwapAction,
BityOrderCreateRequestedSwapAction
} from 'actions/swapTypes';
import { donationAddressMap } from 'config/data';
import { isValidBTCAddress, isValidETHAddress } from 'libs/validators';
import translate from 'translations';
import { combineAndUpper } from 'utils/formatters';
import SimpleButton from 'components/ui/SimpleButton';
export type StateProps = {
isPostingOrder: boolean,
originAmount: number,
originKind: string,
destinationKind: string,
destinationAddress: string
};
export type ActionProps = {
destinationAddressSwap: (value: ?string) => DestinationAddressSwapAction,
changeStepSwap: (value: number) => ChangeStepSwapAction,
stopLoadBityRatesSwap: () => StopLoadBityRatesSwapAction,
bityOrderCreateRequestedSwap: (
amount: number,
destinationAddress: string,
pair: string,
mode: ?number
) => BityOrderCreateRequestedSwapAction
};
export default class ReceivingAddress extends Component {
props: StateProps & ActionProps;
onChangeDestinationAddress = (event: SyntheticInputEvent) => {
const value = event.target.value;
this.props.destinationAddressSwap(value);
};
onClickPartTwoComplete = () => {
this.props.bityOrderCreateRequestedSwap(
this.props.originAmount,
this.props.destinationAddress,
combineAndUpper(this.props.originKind, this.props.destinationKind)
);
};
render() {
const { destinationKind, destinationAddress, isPostingOrder } = this.props;
let validAddress;
// TODO - find better pattern here once currencies move beyond BTC, ETH, REP
if (this.props.destinationKind === 'BTC') {
validAddress = isValidBTCAddress(destinationAddress);
} else {
validAddress = isValidETHAddress(destinationAddress);
}
const inputClasses = classnames({
'SwapAddress-address-input': true,
'form-control': true,
'is-valid': validAddress,
'is-invalid': !validAddress
});
return (
<section className="SwapAddress block">
<section className="row">
<div className="col-sm-8 col-sm-offset-2 col-xs-12">
<label className="SwapAddress-address">
<h4 className="SwapAddress-address-label">
{translate('SWAP_rec_add')} ({destinationKind})
</h4>
<input
className={inputClasses}
type="text"
value={destinationAddress}
onChange={this.onChangeDestinationAddress}
placeholder={donationAddressMap[destinationKind]}
/>
</label>
</div>
</section>
<section className="SwapAddress-submit row">
<SimpleButton
text={translate('SWAP_start_CTA')}
onClick={this.onClickPartTwoComplete}
disabled={!validAddress}
loading={isPostingOrder}
/>
</section>
</section>
);
}
}