2017-09-25 02:06:28 +00:00
|
|
|
import { TShowNotification } from 'actions/notifications';
|
|
|
|
import {
|
|
|
|
TRestartSwap,
|
|
|
|
TStartPollBityOrderStatus,
|
2018-01-02 18:04:50 +00:00
|
|
|
TStartPollShapeshiftOrderStatus,
|
2017-09-25 02:06:28 +00:00
|
|
|
TStopOrderTimerSwap,
|
2018-01-02 18:04:50 +00:00
|
|
|
TStopPollBityOrderStatus,
|
|
|
|
TStopPollShapeshiftOrderStatus
|
2017-09-25 02:06:28 +00:00
|
|
|
} from 'actions/swap';
|
2017-12-11 17:44:53 +00:00
|
|
|
import { SwapInput } from 'reducers/swap/types';
|
2018-01-29 19:13:46 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2017-09-25 02:06:28 +00:00
|
|
|
import BitcoinQR from './BitcoinQR';
|
|
|
|
import PaymentInfo from './PaymentInfo';
|
|
|
|
import SwapProgress from './SwapProgress';
|
2018-01-02 18:04:50 +00:00
|
|
|
import { LiteSend } from './LiteSend';
|
2017-09-25 02:06:28 +00:00
|
|
|
|
|
|
|
interface ReduxStateProps {
|
|
|
|
destinationAddress: string;
|
2017-12-11 17:44:53 +00:00
|
|
|
origin: SwapInput;
|
|
|
|
destination: SwapInput;
|
2017-09-25 02:06:28 +00:00
|
|
|
reference: string;
|
|
|
|
secondsRemaining: number | null;
|
|
|
|
paymentAddress: string | null;
|
2018-01-02 18:04:50 +00:00
|
|
|
provider: string;
|
|
|
|
bityOrderStatus: string | null;
|
|
|
|
shapeshiftOrderStatus: string | null;
|
2017-09-25 02:06:28 +00:00
|
|
|
outputTx: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ReduxActionProps {
|
|
|
|
restartSwap: TRestartSwap;
|
|
|
|
startPollBityOrderStatus: TStartPollBityOrderStatus;
|
|
|
|
stopPollBityOrderStatus: TStopPollBityOrderStatus;
|
2018-01-02 18:04:50 +00:00
|
|
|
startPollShapeshiftOrderStatus: TStartPollShapeshiftOrderStatus;
|
|
|
|
stopPollShapeshiftOrderStatus: TStopPollShapeshiftOrderStatus;
|
|
|
|
stopOrderTimerSwap: TStopOrderTimerSwap;
|
2017-09-25 02:06:28 +00:00
|
|
|
showNotification: TShowNotification;
|
|
|
|
}
|
|
|
|
|
2018-01-29 19:13:46 +00:00
|
|
|
export default class PartThree extends PureComponent<ReduxActionProps & ReduxStateProps, {}> {
|
2017-09-25 02:06:28 +00:00
|
|
|
public componentDidMount() {
|
2018-01-02 18:04:50 +00:00
|
|
|
const { provider } = this.props;
|
|
|
|
if (provider === 'shapeshift') {
|
|
|
|
this.props.startPollShapeshiftOrderStatus();
|
|
|
|
} else {
|
|
|
|
this.props.startPollBityOrderStatus();
|
|
|
|
}
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.props.stopOrderTimerSwap();
|
|
|
|
this.props.stopPollBityOrderStatus();
|
2018-01-02 18:04:50 +00:00
|
|
|
this.props.stopPollShapeshiftOrderStatus();
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
const {
|
|
|
|
// STATE
|
2017-12-11 17:44:53 +00:00
|
|
|
origin,
|
|
|
|
destination,
|
2017-09-25 02:06:28 +00:00
|
|
|
paymentAddress,
|
2018-01-02 18:04:50 +00:00
|
|
|
provider,
|
|
|
|
bityOrderStatus,
|
|
|
|
shapeshiftOrderStatus,
|
2017-09-25 02:06:28 +00:00
|
|
|
destinationAddress,
|
|
|
|
outputTx,
|
|
|
|
// ACTIONS
|
|
|
|
showNotification
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const SwapProgressProps = {
|
2018-03-01 17:53:29 +00:00
|
|
|
originId: origin.label,
|
|
|
|
destinationId: destination.label,
|
2018-01-02 18:04:50 +00:00
|
|
|
provider,
|
|
|
|
bityOrderStatus,
|
|
|
|
shapeshiftOrderStatus,
|
2017-09-25 02:06:28 +00:00
|
|
|
showNotification,
|
|
|
|
destinationAddress,
|
|
|
|
outputTx
|
|
|
|
};
|
|
|
|
|
|
|
|
const PaymentInfoProps = {
|
2017-12-11 17:44:53 +00:00
|
|
|
origin,
|
2017-09-25 02:06:28 +00:00
|
|
|
paymentAddress
|
|
|
|
};
|
|
|
|
|
|
|
|
const BitcoinQRProps = {
|
|
|
|
paymentAddress,
|
2018-01-02 18:04:50 +00:00
|
|
|
destinationAmount: destination.amount as number
|
2017-09-25 02:06:28 +00:00
|
|
|
};
|
|
|
|
|
2018-01-02 18:04:50 +00:00
|
|
|
const OpenOrder = bityOrderStatus === 'OPEN' || shapeshiftOrderStatus === 'no_deposits';
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<SwapProgress {...SwapProgressProps} />
|
2018-01-02 18:04:50 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
<PaymentInfo {...PaymentInfoProps} />
|
2018-01-02 18:04:50 +00:00
|
|
|
|
|
|
|
<LiteSend />
|
2018-03-01 17:53:29 +00:00
|
|
|
{OpenOrder && origin.label === 'BTC' && <BitcoinQR {...BitcoinQRProps} />}
|
2017-09-25 02:06:28 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|