//flow import React, { Component } from 'react'; import translate from 'translations'; import bityConfig from 'config/bity'; export type Props = { destinationKind: string, destinationAddress: string, outputTx: string, originKind: string, orderStatus: string, // actions showNotification: Function }; export default class SwapProgress extends Component { constructor(props) { super(props); this.state = { hasShownViewTx: false }; } props: Props; componentDidMount() { this.showNotification(); } showNotification = () => { const { hasShownViewTx } = this.state; const { destinationKind, outputTx, showNotification, orderStatus } = this.props; if (orderStatus === 'FILL') { if (!hasShownViewTx) { let linkElement; let link; // everything but BTC is a token if (destinationKind !== 'BTC') { link = bityConfig.ethExplorer.replace('[[txHash]]', outputTx); linkElement = ` View your transaction `; // BTC uses a different explorer } else { link = bityConfig.btcExplorer.replace('[[txHash]]', outputTx); linkElement = ` View your transaction `; } this.setState({ hasShownViewTx: true }, () => { showNotification('success', linkElement); }); } } }; computedClass = (step: number) => { const { orderStatus } = this.props; let cssClass = 'progress-item'; switch (orderStatus) { case 'OPEN': if (step < 2) { return cssClass + ' progress-true'; } else if (step === 2) { return cssClass + ' progress-active'; } else { return cssClass; } case 'RCVE': if (step < 4) { return cssClass + ' progress-true'; } else if (step === 4) { return cssClass + ' progress-active'; } else { return cssClass; } case 'FILL': cssClass += ' progress-true'; return cssClass; case 'CANC': return cssClass; default: return cssClass; } }; render() { const { destinationKind, originKind } = this.props; const numberOfConfirmations = originKind === 'BTC' ? '3' : '10'; return (
1

{translate('SWAP_progress_1')}

2

{translate('SWAP_progress_2')} {originKind}...

3

{originKind} {translate('SWAP_progress_3')}

4

Sending your {destinationKind}
Waiting for {numberOfConfirmations} confirmations...

5

Order Complete

); } }