blob: d6e7303dd0945e37e89cf513c363b408c5fc4333 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { AssetBuyer, BuyQuote } from '@0x/asset-buyer';
import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { State } from '../redux/reducer';
import { AsyncProcessState } from '../types';
import { SelectedAssetBuyButton } from './selected_asset_buy_button';
import { SelectedAssetRetryButton } from './selected_asset_retry_button';
interface ConnectedState {
buyOrderState: AsyncProcessState;
}
export interface SelectedAssetButtonProps {}
const mapStateToProps = (state: State, _ownProps: SelectedAssetButtonProps): ConnectedState => ({
buyOrderState: state.buyOrderState,
});
const SelectedAssetButtonPresentationComponent: React.StatelessComponent<{
buyOrderState: AsyncProcessState;
}> = props => {
if (props.buyOrderState === AsyncProcessState.FAILURE) {
return <SelectedAssetRetryButton />;
}
return <SelectedAssetBuyButton />;
};
export const SelectedAssetButton: React.ComponentClass<SelectedAssetButtonProps> = connect(mapStateToProps)(
SelectedAssetButtonPresentationComponent,
);
|