2017-09-25 02:06:28 +00:00
|
|
|
import {
|
|
|
|
TBityOrderCreateRequestedSwap,
|
|
|
|
TChangeStepSwap,
|
|
|
|
TDestinationAddressSwap,
|
|
|
|
TStopLoadBityRatesSwap
|
|
|
|
} from 'actions/swap';
|
2017-12-11 17:44:53 +00:00
|
|
|
import { SwapInput } from 'reducers/swap/types';
|
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 19:52:01 +00:00
|
|
|
import classnames from 'classnames';
|
2017-09-25 02:06:28 +00:00
|
|
|
import SimpleButton from 'components/ui/SimpleButton';
|
2017-07-04 00:16:20 +00:00
|
|
|
import { donationAddressMap } from 'config/data';
|
2017-07-02 05:49:06 +00:00
|
|
|
import { isValidBTCAddress, isValidETHAddress } from 'libs/validators';
|
2017-09-25 02:06:28 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-06-25 05:57:43 +00:00
|
|
|
import translate from 'translations';
|
2017-07-31 23:14:30 +00:00
|
|
|
import { combineAndUpper } from 'utils/formatters';
|
2017-09-25 02:06:28 +00:00
|
|
|
import './ReceivingAddress.scss';
|
2017-07-22 21:24:03 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export interface StateProps {
|
2017-12-11 17:44:53 +00:00
|
|
|
origin: SwapInput;
|
2017-12-19 22:46:34 +00:00
|
|
|
destinationId: keyof typeof donationAddressMap;
|
2017-09-25 02:06:28 +00:00
|
|
|
isPostingOrder: boolean;
|
|
|
|
destinationAddress: string;
|
|
|
|
}
|
2017-07-22 21:24:03 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export interface ActionProps {
|
|
|
|
destinationAddressSwap: TDestinationAddressSwap;
|
|
|
|
changeStepSwap: TChangeStepSwap;
|
|
|
|
stopLoadBityRatesSwap: TStopLoadBityRatesSwap;
|
|
|
|
bityOrderCreateRequestedSwap: TBityOrderCreateRequestedSwap;
|
|
|
|
}
|
2017-06-24 06:09:44 +00:00
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
export default class ReceivingAddress extends Component<StateProps & ActionProps, {}> {
|
2017-12-19 22:46:34 +00:00
|
|
|
public onChangeDestinationAddress = (event: React.FormEvent<HTMLInputElement>) => {
|
|
|
|
const value = event.currentTarget.value;
|
2017-07-02 05:45:22 +00:00
|
|
|
this.props.destinationAddressSwap(value);
|
2017-06-24 01:26:54 +00:00
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public onClickPartTwoComplete = () => {
|
2017-12-11 17:44:53 +00:00
|
|
|
const { origin, destinationId } = this.props;
|
|
|
|
if (!origin) {
|
2017-09-25 02:06:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-07-31 23:14:30 +00:00
|
|
|
this.props.bityOrderCreateRequestedSwap(
|
2017-12-11 17:44:53 +00:00
|
|
|
origin.amount,
|
2017-07-31 23:14:30 +00:00
|
|
|
this.props.destinationAddress,
|
2017-12-11 17:44:53 +00:00
|
|
|
combineAndUpper(origin.id, destinationId)
|
2017-07-31 23:14:30 +00:00
|
|
|
);
|
2017-07-02 05:45:22 +00:00
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public render() {
|
2017-12-11 17:44:53 +00:00
|
|
|
const { destinationId, destinationAddress, isPostingOrder } = this.props;
|
2017-06-24 06:09:44 +00:00
|
|
|
let validAddress;
|
|
|
|
// TODO - find better pattern here once currencies move beyond BTC, ETH, REP
|
2017-12-11 17:44:53 +00:00
|
|
|
if (destinationId === 'BTC') {
|
2017-07-02 05:49:06 +00:00
|
|
|
validAddress = isValidBTCAddress(destinationAddress);
|
2017-06-24 06:09:44 +00:00
|
|
|
} else {
|
2017-07-02 05:49:06 +00:00
|
|
|
validAddress = isValidETHAddress(destinationAddress);
|
2017-06-24 06:09:44 +00:00
|
|
|
}
|
2017-06-24 01:26:54 +00:00
|
|
|
|
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 19:52:01 +00:00
|
|
|
const inputClasses = classnames({
|
|
|
|
'SwapAddress-address-input': true,
|
|
|
|
'form-control': true,
|
|
|
|
'is-valid': validAddress,
|
|
|
|
'is-invalid': !validAddress
|
|
|
|
});
|
|
|
|
|
2017-06-24 01:26:54 +00:00
|
|
|
return (
|
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 19:52:01 +00:00
|
|
|
<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">
|
2017-12-11 17:44:53 +00:00
|
|
|
{translate('SWAP_rec_add')} ({destinationId})
|
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 19:52:01 +00:00
|
|
|
</h4>
|
|
|
|
|
2017-06-24 01:26:54 +00:00
|
|
|
<input
|
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 19:52:01 +00:00
|
|
|
className={inputClasses}
|
2017-06-24 01:26:54 +00:00
|
|
|
type="text"
|
2017-07-02 05:45:22 +00:00
|
|
|
value={destinationAddress}
|
|
|
|
onChange={this.onChangeDestinationAddress}
|
2017-12-11 17:44:53 +00:00
|
|
|
placeholder={donationAddressMap[destinationId]}
|
2017-06-24 01:26:54 +00:00
|
|
|
/>
|
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 19:52:01 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section className="SwapAddress-submit row">
|
|
|
|
<SimpleButton
|
|
|
|
text={translate('SWAP_start_CTA')}
|
|
|
|
onClick={this.onClickPartTwoComplete}
|
|
|
|
disabled={!validAddress}
|
|
|
|
loading={isPostingOrder}
|
|
|
|
/>
|
2017-06-24 01:26:54 +00:00
|
|
|
</section>
|
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 19:52:01 +00:00
|
|
|
</section>
|
2017-06-24 01:26:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|