blob: d84ae1a527d4570e788069bf1e034d82ffc355f4 (
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
|
import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-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,
);
|