aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers/selected_asset_instant_heading.ts
blob: 8dc127e1d78f82dc440ea89f20dd0f435ab70d36 (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
34
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { oc } from 'ts-optchain';

import { State } from '../redux/reducer';
import { AsyncProcessState, ERC20Asset, OrderState } from '../types';

import { InstantHeading } from '../components/instant_heading';

export interface InstantHeadingProps {
    onSelectAssetClick?: (asset?: ERC20Asset) => void;
}

interface ConnectedState {
    selectedAssetUnitAmount?: BigNumber;
    totalEthBaseUnitAmount?: BigNumber;
    ethUsdPrice?: BigNumber;
    quoteRequestState: AsyncProcessState;
    buyOrderState: OrderState;
}

const mapStateToProps = (state: State, _ownProps: InstantHeadingProps): ConnectedState => ({
    selectedAssetUnitAmount: state.selectedAssetUnitAmount,
    totalEthBaseUnitAmount: oc(state).latestBuyQuote.worstCaseQuoteInfo.totalEthAmount(),
    ethUsdPrice: state.ethUsdPrice,
    quoteRequestState: state.quoteRequestState,
    buyOrderState: state.buyOrderState,
});

export const SelectedAssetInstantHeading: React.ComponentClass<InstantHeadingProps> = connect(mapStateToProps)(
    InstantHeading,
);