2018-01-02 18:04:50 +00:00
|
|
|
import { TChangeStepSwap, TInitSwap, TChangeSwapProvider, ProviderName } from 'actions/swap';
|
|
|
|
import {
|
|
|
|
NormalizedBityRates,
|
|
|
|
NormalizedShapeshiftRates,
|
|
|
|
NormalizedOptions,
|
|
|
|
SwapInput
|
|
|
|
} from 'reducers/swap/types';
|
2017-09-25 02:06:28 +00:00
|
|
|
import SimpleButton from 'components/ui/SimpleButton';
|
2018-01-20 20:06:28 +00:00
|
|
|
import { generateKindMax, generateKindMin, WhitelistedCoins, bityConfig } from 'config/bity';
|
2018-01-29 19:13:46 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2018-03-22 03:50:25 +00:00
|
|
|
import translate, { translateRaw } from 'translations';
|
2017-12-11 17:44:53 +00:00
|
|
|
import { combineAndUpper } from 'utils/formatters';
|
2018-03-01 17:53:29 +00:00
|
|
|
import { SwapDropdown, Input } from 'components/ui';
|
2017-11-14 18:37:56 +00:00
|
|
|
import Spinner from 'components/ui/Spinner';
|
2018-03-23 16:25:44 +00:00
|
|
|
import { merge, debounce } from 'lodash';
|
2017-12-11 17:44:53 +00:00
|
|
|
import './CurrencySwap.scss';
|
2017-09-25 02:06:28 +00:00
|
|
|
|
|
|
|
export interface StateProps {
|
2017-12-11 17:44:53 +00:00
|
|
|
bityRates: NormalizedBityRates;
|
2018-01-02 18:04:50 +00:00
|
|
|
shapeshiftRates: NormalizedShapeshiftRates;
|
|
|
|
provider: ProviderName;
|
2017-12-11 17:44:53 +00:00
|
|
|
options: NormalizedOptions;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ActionProps {
|
|
|
|
changeStepSwap: TChangeStepSwap;
|
2017-12-11 17:44:53 +00:00
|
|
|
initSwap: TInitSwap;
|
2018-01-02 18:04:50 +00:00
|
|
|
swapProvider: TChangeSwapProvider;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface State {
|
2018-03-23 16:25:44 +00:00
|
|
|
options: any[];
|
2017-09-25 02:06:28 +00:00
|
|
|
disabled: boolean;
|
2018-03-07 23:36:05 +00:00
|
|
|
origin: SwapOpt;
|
|
|
|
destination: SwapOpt;
|
2017-11-14 18:37:56 +00:00
|
|
|
originErr: string;
|
|
|
|
destinationErr: string;
|
2018-01-02 18:04:50 +00:00
|
|
|
timeout: boolean;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
2017-09-25 03:29:49 +00:00
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
type Props = StateProps & ActionProps;
|
|
|
|
|
2018-03-01 17:53:29 +00:00
|
|
|
interface SwapOpt extends SwapInput {
|
|
|
|
value: string;
|
|
|
|
status: string;
|
|
|
|
image: string;
|
|
|
|
amount: number;
|
|
|
|
}
|
|
|
|
|
2018-01-29 19:13:46 +00:00
|
|
|
export default class CurrencySwap extends PureComponent<Props, State> {
|
2018-03-07 23:36:05 +00:00
|
|
|
public state: State = {
|
2018-03-23 16:25:44 +00:00
|
|
|
options: [],
|
2017-07-31 23:14:30 +00:00
|
|
|
disabled: true,
|
2018-01-02 18:04:50 +00:00
|
|
|
origin: {
|
2018-03-01 17:53:29 +00:00
|
|
|
label: 'BTC',
|
|
|
|
value: 'Bitcoin',
|
2018-01-02 18:04:50 +00:00
|
|
|
status: 'available',
|
|
|
|
image: 'https://shapeshift.io/images/coins/bitcoin.png',
|
|
|
|
amount: NaN
|
2018-03-07 23:36:05 +00:00
|
|
|
},
|
2018-01-02 18:04:50 +00:00
|
|
|
destination: {
|
2018-03-01 17:53:29 +00:00
|
|
|
label: 'ETH',
|
|
|
|
value: 'Ether',
|
2018-01-02 18:04:50 +00:00
|
|
|
status: 'available',
|
|
|
|
image: 'https://shapeshift.io/images/coins/ether.png',
|
|
|
|
amount: NaN
|
2018-03-07 23:36:05 +00:00
|
|
|
},
|
2017-11-14 18:37:56 +00:00
|
|
|
originErr: '',
|
2018-01-02 18:04:50 +00:00
|
|
|
destinationErr: '',
|
|
|
|
timeout: false
|
2017-07-31 23:14:30 +00:00
|
|
|
};
|
|
|
|
|
2018-01-02 18:04:50 +00:00
|
|
|
public debouncedCreateErrString = debounce((origin, destination, showError) => {
|
|
|
|
const createErrString = (
|
|
|
|
originKind: WhitelistedCoins,
|
|
|
|
amount: number,
|
|
|
|
destKind: WhitelistedCoins
|
|
|
|
) => {
|
|
|
|
const rate = this.getMinMax(originKind, destKind);
|
|
|
|
let errString;
|
|
|
|
if (amount > rate.max) {
|
2018-03-22 03:50:25 +00:00
|
|
|
errString = translateRaw('SWAP_MAX_ERROR', {
|
|
|
|
$rate_max: rate.max.toString(),
|
|
|
|
$origin_id: originKind
|
|
|
|
});
|
2018-01-02 18:04:50 +00:00
|
|
|
} else {
|
2018-03-22 03:50:25 +00:00
|
|
|
errString = translateRaw('SWAP_MIN_ERROR', {
|
|
|
|
$rate_max: rate.min.toString(),
|
|
|
|
$origin_id: originKind
|
|
|
|
});
|
2018-01-02 18:04:50 +00:00
|
|
|
}
|
|
|
|
return errString;
|
|
|
|
};
|
2018-03-01 17:53:29 +00:00
|
|
|
const originErr = showError
|
|
|
|
? createErrString(origin.label, origin.amount, destination.label)
|
|
|
|
: '';
|
2018-01-02 18:04:50 +00:00
|
|
|
const destinationErr = showError
|
2018-03-01 17:53:29 +00:00
|
|
|
? createErrString(destination.label, destination.amount, origin.label)
|
2018-01-02 18:04:50 +00:00
|
|
|
: '';
|
|
|
|
this.setErrorMessages(originErr, destinationErr);
|
|
|
|
}, 1000);
|
|
|
|
|
2018-02-25 01:29:34 +00:00
|
|
|
private timeoutId: NodeJS.Timer | null;
|
2018-01-02 18:04:50 +00:00
|
|
|
public componentDidMount() {
|
2018-02-25 01:29:34 +00:00
|
|
|
this.timeoutId = setTimeout(() => {
|
2018-01-02 18:04:50 +00:00
|
|
|
this.setState({
|
|
|
|
timeout: true
|
|
|
|
});
|
|
|
|
}, 10000);
|
|
|
|
|
2018-03-23 16:25:44 +00:00
|
|
|
this.setState({ options: Object.values(this.props.options.byId) });
|
2018-01-02 18:04:50 +00:00
|
|
|
}
|
|
|
|
|
2018-02-25 01:29:34 +00:00
|
|
|
public componentWillUnmount() {
|
|
|
|
if (this.timeoutId) {
|
|
|
|
clearTimeout(this.timeoutId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-23 16:25:44 +00:00
|
|
|
public componentWillReceiveProps(nextProps: Props) {
|
|
|
|
if (nextProps.options !== this.props.options) {
|
|
|
|
this.setState({ options: Object.values(nextProps.options.byId) });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public componentDidUpdate(_: Props, prevState: State) {
|
2017-12-11 17:44:53 +00:00
|
|
|
const { origin, destination } = this.state;
|
|
|
|
if (origin !== prevState.origin) {
|
|
|
|
this.setDisabled(origin, destination);
|
|
|
|
}
|
2017-11-14 18:37:56 +00:00
|
|
|
}
|
|
|
|
|
2018-01-02 18:04:50 +00:00
|
|
|
public rateMixer = () => {
|
|
|
|
const { shapeshiftRates, bityRates } = this.props;
|
|
|
|
return merge(shapeshiftRates, bityRates);
|
|
|
|
};
|
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
public getMinMax = (originKind: WhitelistedCoins, destinationKind: string) => {
|
2017-12-11 17:44:53 +00:00
|
|
|
let min;
|
|
|
|
let max;
|
2018-01-02 18:04:50 +00:00
|
|
|
|
|
|
|
const { provider, bityRates } = this.props;
|
|
|
|
|
|
|
|
if (provider === 'bity' && bityRates.allIds.length > 2) {
|
|
|
|
if (originKind !== 'BTC') {
|
|
|
|
const pairRate = this.rateMixer().byId['BTC' + originKind].rate;
|
|
|
|
min = generateKindMin(pairRate, originKind);
|
|
|
|
max = generateKindMax(pairRate, originKind);
|
|
|
|
} else {
|
|
|
|
min = bityConfig.BTCMin;
|
|
|
|
max = bityConfig.BTCMax;
|
|
|
|
}
|
2017-07-31 23:14:30 +00:00
|
|
|
} else {
|
2018-01-02 18:04:50 +00:00
|
|
|
const pair = (this.rateMixer() as NormalizedShapeshiftRates).byId[
|
|
|
|
originKind + destinationKind
|
|
|
|
];
|
|
|
|
min = pair.min;
|
|
|
|
max = pair.limit;
|
2017-07-31 23:14:30 +00:00
|
|
|
}
|
2017-12-11 17:44:53 +00:00
|
|
|
return { min, max };
|
2017-07-31 23:14:30 +00:00
|
|
|
};
|
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
public isMinMaxValid = (
|
|
|
|
originAmount: number,
|
|
|
|
originKind: WhitelistedCoins,
|
|
|
|
destinationKind: string
|
|
|
|
) => {
|
2018-01-02 18:04:50 +00:00
|
|
|
const rate = this.getMinMax(originKind, destinationKind);
|
|
|
|
const higherThanMin = originAmount >= rate.min;
|
|
|
|
const lowerThanMax = originAmount <= rate.max;
|
2017-12-11 17:44:53 +00:00
|
|
|
return higherThanMin && lowerThanMax;
|
2017-07-31 23:14:30 +00:00
|
|
|
};
|
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
public setDisabled(origin: SwapInput, destination: SwapInput) {
|
2018-01-02 18:04:50 +00:00
|
|
|
this.clearErrMessages();
|
2017-12-11 17:44:53 +00:00
|
|
|
const amountsValid = origin.amount && destination.amount;
|
2018-03-01 17:53:29 +00:00
|
|
|
const minMaxValid = this.isMinMaxValid(
|
|
|
|
origin.amount as number,
|
|
|
|
origin.label,
|
|
|
|
destination.label
|
|
|
|
);
|
2017-12-11 17:44:53 +00:00
|
|
|
const disabled = !(amountsValid && minMaxValid);
|
2018-01-02 18:04:50 +00:00
|
|
|
const showError = disabled && amountsValid;
|
2017-07-31 23:14:30 +00:00
|
|
|
|
2018-01-02 18:04:50 +00:00
|
|
|
this.setState({
|
|
|
|
disabled
|
|
|
|
});
|
2017-11-14 18:37:56 +00:00
|
|
|
|
2018-01-02 18:04:50 +00:00
|
|
|
this.debouncedCreateErrString(origin, destination, showError);
|
|
|
|
}
|
2017-11-14 18:37:56 +00:00
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
public setErrorMessages = (originErr: string, destinationErr: string) => {
|
2017-12-11 17:44:53 +00:00
|
|
|
this.setState({
|
|
|
|
originErr,
|
|
|
|
destinationErr
|
|
|
|
});
|
2018-01-02 18:04:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public clearErrMessages = () => {
|
|
|
|
this.setState({
|
|
|
|
originErr: '',
|
|
|
|
destinationErr: ''
|
|
|
|
});
|
|
|
|
};
|
2017-07-31 23:14:30 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public onClickStartSwap = () => {
|
2017-12-11 17:44:53 +00:00
|
|
|
const { origin, destination } = this.state;
|
|
|
|
const { changeStepSwap, initSwap } = this.props;
|
|
|
|
initSwap({ origin, destination });
|
|
|
|
changeStepSwap(2);
|
2017-07-31 23:14:30 +00:00
|
|
|
};
|
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
public setOriginAndDestinationToInitialVal = () => {
|
|
|
|
this.setState({
|
|
|
|
origin: { ...this.state.origin, amount: NaN },
|
|
|
|
destination: { ...this.state.destination, amount: NaN }
|
|
|
|
});
|
2017-07-31 23:14:30 +00:00
|
|
|
};
|
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
public updateOriginAmount = (origin: SwapInput, destination: SwapInput, amount: number) => {
|
|
|
|
if (amount || amount === 0) {
|
2018-03-01 17:53:29 +00:00
|
|
|
const pairName = combineAndUpper(origin.label, destination.label);
|
2018-01-02 18:04:50 +00:00
|
|
|
const rate = this.rateMixer().byId[pairName].rate;
|
|
|
|
const destinationAmount = amount * rate;
|
2017-12-11 17:44:53 +00:00
|
|
|
this.setState({
|
|
|
|
origin: { ...this.state.origin, amount },
|
|
|
|
destination: { ...this.state.destination, amount: destinationAmount }
|
|
|
|
});
|
2017-07-31 23:14:30 +00:00
|
|
|
} else {
|
2017-12-11 17:44:53 +00:00
|
|
|
this.setOriginAndDestinationToInitialVal();
|
2017-07-31 23:14:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
public updateDestinationAmount = (origin: SwapInput, destination: SwapInput, amount: number) => {
|
|
|
|
if (amount || amount === 0) {
|
2018-03-01 17:53:29 +00:00
|
|
|
const pairNameReversed = combineAndUpper(destination.label, origin.label);
|
2018-01-02 18:04:50 +00:00
|
|
|
const rate = this.rateMixer().byId[pairNameReversed].rate;
|
|
|
|
const originAmount = amount * rate;
|
2017-12-11 17:44:53 +00:00
|
|
|
this.setState({
|
|
|
|
origin: { ...this.state.origin, amount: originAmount },
|
|
|
|
destination: {
|
|
|
|
...this.state.destination,
|
|
|
|
amount
|
|
|
|
}
|
|
|
|
});
|
2017-07-31 23:14:30 +00:00
|
|
|
} else {
|
2017-12-11 17:44:53 +00:00
|
|
|
this.setOriginAndDestinationToInitialVal();
|
2017-07-31 23:14:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-19 22:46:34 +00:00
|
|
|
public onChangeAmount = (event: React.FormEvent<HTMLInputElement>) => {
|
|
|
|
const type = event.currentTarget.id;
|
2017-12-11 17:44:53 +00:00
|
|
|
const { origin, destination } = this.state;
|
2017-12-19 22:46:34 +00:00
|
|
|
const amount = parseFloat(event.currentTarget.value);
|
2017-12-11 17:44:53 +00:00
|
|
|
type === 'origin-swap-input'
|
|
|
|
? this.updateOriginAmount(origin, destination, amount)
|
|
|
|
: this.updateDestinationAmount(origin, destination, amount);
|
|
|
|
};
|
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
public onChangeOriginKind = (newOption: any) => {
|
2018-03-23 16:25:44 +00:00
|
|
|
const { origin, destination } = this.state;
|
|
|
|
const { initSwap } = this.props;
|
2018-01-02 18:04:50 +00:00
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
const newOrigin = { ...origin, label: newOption.label, value: newOption.value, amount: 0 };
|
2018-01-02 18:04:50 +00:00
|
|
|
const newDest = {
|
2018-03-01 17:53:29 +00:00
|
|
|
label: newOption.label === destination.label ? origin.label : destination.label,
|
|
|
|
value: newOption.value === destination.value ? origin.value : destination.value,
|
2018-03-07 23:36:05 +00:00
|
|
|
amount: 0,
|
|
|
|
status: '',
|
|
|
|
image: ''
|
2017-12-11 17:44:53 +00:00
|
|
|
};
|
2018-03-01 17:53:29 +00:00
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
this.setState({
|
2018-01-02 18:04:50 +00:00
|
|
|
origin: newOrigin,
|
2018-03-23 16:25:44 +00:00
|
|
|
destination: newDest
|
2017-12-11 17:44:53 +00:00
|
|
|
});
|
2018-01-02 18:04:50 +00:00
|
|
|
|
|
|
|
initSwap({ origin: newOrigin, destination: newDest });
|
2017-12-11 17:44:53 +00:00
|
|
|
};
|
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
public onChangeDestinationKind = (newOption: any) => {
|
2018-01-02 18:04:50 +00:00
|
|
|
const { initSwap } = this.props;
|
2017-12-11 17:44:53 +00:00
|
|
|
const { origin, destination } = this.state;
|
2018-01-02 18:04:50 +00:00
|
|
|
|
|
|
|
const newOrigin = {
|
|
|
|
...origin,
|
2018-03-07 23:36:05 +00:00
|
|
|
amount: 0
|
2017-12-11 17:44:53 +00:00
|
|
|
};
|
2018-01-02 18:04:50 +00:00
|
|
|
|
2018-03-07 23:36:05 +00:00
|
|
|
const newDest = { ...destination, label: newOption.label, value: newOption.value, amount: 0 };
|
2017-12-11 17:44:53 +00:00
|
|
|
this.setState({
|
2018-01-02 18:04:50 +00:00
|
|
|
origin: newOrigin,
|
|
|
|
destination: newDest
|
2017-12-11 17:44:53 +00:00
|
|
|
});
|
2018-01-02 18:04:50 +00:00
|
|
|
|
|
|
|
initSwap({ origin: newOrigin, destination: newDest });
|
2017-12-11 17:44:53 +00:00
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public render() {
|
2018-01-02 18:04:50 +00:00
|
|
|
const { bityRates, shapeshiftRates, provider } = this.props;
|
2018-03-23 16:25:44 +00:00
|
|
|
const { options, origin, destination, originErr, destinationErr, timeout } = this.state;
|
2018-03-01 17:53:29 +00:00
|
|
|
const pairName = combineAndUpper(origin.label, destination.label);
|
2018-01-02 18:04:50 +00:00
|
|
|
const bityLoaded = bityRates.byId && bityRates.byId[pairName] ? true : false;
|
|
|
|
const shapeshiftLoaded = shapeshiftRates.byId && shapeshiftRates.byId[pairName] ? true : false;
|
|
|
|
// This ensures both are loaded
|
|
|
|
const loaded = provider === 'shapeshift' ? shapeshiftLoaded : bityLoaded && shapeshiftLoaded;
|
|
|
|
const timeoutLoaded = (bityLoaded && timeout) || (shapeshiftLoaded && timeout);
|
2017-07-31 23:14:30 +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
|
|
|
<article className="CurrencySwap">
|
2018-01-02 18:04:50 +00:00
|
|
|
{loaded || timeoutLoaded ? (
|
2018-03-01 17:53:29 +00:00
|
|
|
<React.Fragment>
|
|
|
|
<div className="CurrencySwap-inner-wrap">
|
|
|
|
<div className="flex-spacer" />
|
|
|
|
<div className="input-group-wrapper">
|
2018-03-22 03:50:25 +00:00
|
|
|
<div className="input-group-header">{translate('SWAP_DEPOSIT_INPUT_LABEL')}</div>
|
2018-03-23 16:25:44 +00:00
|
|
|
<div className="input-group input-group-inline">
|
2018-03-01 17:53:29 +00:00
|
|
|
<Input
|
|
|
|
id="origin-swap-input"
|
|
|
|
className={`input-group-input ${
|
2018-03-23 16:41:47 +00:00
|
|
|
!!origin.amount &&
|
2018-03-01 17:53:29 +00:00
|
|
|
this.isMinMaxValid(origin.amount, origin.label, destination.label)
|
|
|
|
? ''
|
|
|
|
: 'invalid'
|
|
|
|
}`}
|
|
|
|
type="number"
|
2018-03-22 03:50:25 +00:00
|
|
|
placeholder={translateRaw('SEND_AMOUNT_SHORT')}
|
2018-03-01 17:53:29 +00:00
|
|
|
value={isNaN(origin.amount) ? '' : origin.amount}
|
|
|
|
onChange={this.onChangeAmount}
|
|
|
|
/>
|
|
|
|
<SwapDropdown
|
2018-03-23 16:25:44 +00:00
|
|
|
options={options}
|
2018-03-01 17:53:29 +00:00
|
|
|
value={origin.value}
|
|
|
|
onChange={this.onChangeOriginKind}
|
|
|
|
/>
|
2018-03-23 16:25:44 +00:00
|
|
|
</div>
|
2018-03-01 17:53:29 +00:00
|
|
|
{originErr && <span className="CurrencySwap-error-message">{originErr}</span>}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="input-group-wrapper">
|
2018-03-23 16:25:44 +00:00
|
|
|
<div className="input-group input-group-inline">
|
2018-03-26 17:48:41 +00:00
|
|
|
<div className="input-group-header">{translate('SWAP_RECEIVE_INPUT_LABEL')}</div>
|
2018-03-01 17:53:29 +00:00
|
|
|
<Input
|
|
|
|
id="destination-swap-input"
|
|
|
|
className={`${
|
2018-03-23 16:41:47 +00:00
|
|
|
!!destination.amount &&
|
2018-03-01 17:53:29 +00:00
|
|
|
this.isMinMaxValid(origin.amount, origin.label, destination.label)
|
|
|
|
? ''
|
|
|
|
: 'invalid'
|
|
|
|
}`}
|
|
|
|
type="number"
|
2018-03-22 03:50:25 +00:00
|
|
|
placeholder={translateRaw('SEND_AMOUNT_SHORT')}
|
2018-03-01 17:53:29 +00:00
|
|
|
value={isNaN(destination.amount) ? '' : destination.amount}
|
|
|
|
onChange={this.onChangeAmount}
|
|
|
|
/>
|
|
|
|
<SwapDropdown
|
2018-03-23 16:25:44 +00:00
|
|
|
options={options}
|
|
|
|
disabledOption={origin.value}
|
2018-03-01 17:53:29 +00:00
|
|
|
value={destination.value}
|
|
|
|
onChange={this.onChangeDestinationKind}
|
|
|
|
/>
|
2018-03-23 16:25:44 +00:00
|
|
|
</div>
|
2018-03-01 17:53:29 +00:00
|
|
|
{destinationErr && (
|
|
|
|
<span className="CurrencySwap-error-message">{destinationErr}</span>
|
|
|
|
)}
|
2017-11-14 18:37:56 +00:00
|
|
|
</div>
|
2018-03-01 17:53:29 +00:00
|
|
|
<div className="flex-spacer" />
|
2017-11-14 18:37:56 +00:00
|
|
|
</div>
|
2018-03-01 17:53:29 +00:00
|
|
|
<div className="CurrencySwap-submit">
|
|
|
|
<SimpleButton
|
|
|
|
onClick={this.onClickStartSwap}
|
2018-03-22 03:50:25 +00:00
|
|
|
text={translateRaw('SWAP_INIT_CTA')}
|
2018-03-01 17:53:29 +00:00
|
|
|
disabled={this.state.disabled}
|
|
|
|
type="primary"
|
2017-11-14 18:37:56 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2018-03-01 17:53:29 +00:00
|
|
|
</React.Fragment>
|
2017-11-14 18:37:56 +00:00
|
|
|
) : (
|
|
|
|
<Spinner />
|
|
|
|
)}
|
2017-07-31 23:14:30 +00:00
|
|
|
</article>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|