diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-17 02:25:52 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-18 05:44:39 +0800 |
commit | db77cd10c550803c4f3fac585adc0a7f6ffa8999 (patch) | |
tree | d575b28199e32fd0ebdbac831e3839cc4fa2aa10 /packages/instant/src/containers/latest_error.tsx | |
parent | f36352be47a3caf92e16e3965c86b593bfc46fea (diff) | |
download | dexon-0x-contracts-db77cd10c550803c4f3fac585adc0a7f6ffa8999.tar.gz dexon-0x-contracts-db77cd10c550803c4f3fac585adc0a7f6ffa8999.tar.zst dexon-0x-contracts-db77cd10c550803c4f3fac585adc0a7f6ffa8999.zip |
feat(instant): Handle AssetBuyer errors
Diffstat (limited to 'packages/instant/src/containers/latest_error.tsx')
-rw-r--r-- | packages/instant/src/containers/latest_error.tsx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/instant/src/containers/latest_error.tsx b/packages/instant/src/containers/latest_error.tsx new file mode 100644 index 000000000..5272d9610 --- /dev/null +++ b/packages/instant/src/containers/latest_error.tsx @@ -0,0 +1,36 @@ +import * as React from 'react'; + +import { connect } from 'react-redux'; + +import { SlidingError } from '../components/sliding_error'; +import { State } from '../redux/reducer'; +import { errorDescription } from '../util/error_description'; + +export interface LatestErrorComponentProps { + assetData?: string; + latestError?: any; + latestErrorDismissed?: boolean; +} + +export const LatestErrorComponent: React.StatelessComponent<LatestErrorComponentProps> = props => { + if (!props.latestError) { + return <div />; + } + const slidingDirection = props.latestErrorDismissed ? 'down' : 'up'; + const { icon, message } = errorDescription(props.latestError, props.assetData); + return <SlidingError direction={slidingDirection} icon={icon} message={message} />; +}; + +interface ConnectedState { + assetData?: string; + latestError?: any; + latestErrorDismissed?: boolean; +} +export interface LatestErrorProps {} +const mapStateToProps = (state: State, _ownProps: LatestErrorProps): ConnectedState => ({ + assetData: state.selectedAssetData, + latestError: state.latestError, + latestErrorDismissed: state.latestErrorDismissed, +}); + +export const LatestError = connect(mapStateToProps)(LatestErrorComponent); |