Moved LatestErrorDisplay to types file and gave generic name
This commit is contained in:
@@ -3,7 +3,8 @@ import * as React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { SlidingError } from '../components/sliding_error';
|
||||
import { LatestErrorDisplay, State } from '../redux/reducer';
|
||||
import { State } from '../redux/reducer';
|
||||
import { DisplayStatus } from '../types';
|
||||
import { errorUtil } from '../util/error';
|
||||
|
||||
export interface LatestErrorComponentProps {
|
||||
@@ -29,7 +30,7 @@ export interface LatestErrorProps {}
|
||||
const mapStateToProps = (state: State, _ownProps: LatestErrorProps): ConnectedState => ({
|
||||
assetData: state.selectedAssetData,
|
||||
latestError: state.latestError,
|
||||
slidingDirection: state.latestErrorDisplay === LatestErrorDisplay.Present ? 'up' : 'down',
|
||||
slidingDirection: state.latestErrorDisplay === DisplayStatus.Present ? 'up' : 'down',
|
||||
});
|
||||
|
||||
export const LatestError = connect(mapStateToProps)(LatestErrorComponent);
|
||||
|
||||
@@ -3,14 +3,10 @@ import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { zrxAssetData } from '../constants';
|
||||
import { AsyncProcessState } from '../types';
|
||||
import { AsyncProcessState, DisplayStatus } from '../types';
|
||||
|
||||
import { Action, ActionTypes } from './actions';
|
||||
|
||||
export enum LatestErrorDisplay {
|
||||
Present,
|
||||
Hidden,
|
||||
}
|
||||
export interface State {
|
||||
selectedAssetData?: string;
|
||||
selectedAssetAmount?: BigNumber;
|
||||
@@ -19,7 +15,7 @@ export interface State {
|
||||
latestBuyQuote?: BuyQuote;
|
||||
quoteRequestState: AsyncProcessState;
|
||||
latestError?: any;
|
||||
latestErrorDisplay: LatestErrorDisplay;
|
||||
latestErrorDisplay: DisplayStatus;
|
||||
}
|
||||
|
||||
export const INITIAL_STATE: State = {
|
||||
@@ -30,7 +26,7 @@ export const INITIAL_STATE: State = {
|
||||
ethUsdPrice: undefined,
|
||||
latestBuyQuote: undefined,
|
||||
latestError: undefined,
|
||||
latestErrorDisplay: LatestErrorDisplay.Hidden,
|
||||
latestErrorDisplay: DisplayStatus.Hidden,
|
||||
quoteRequestState: AsyncProcessState.NONE,
|
||||
};
|
||||
|
||||
@@ -73,18 +69,18 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
|
||||
return {
|
||||
...state,
|
||||
latestError: action.data,
|
||||
latestErrorDisplay: LatestErrorDisplay.Present,
|
||||
latestErrorDisplay: DisplayStatus.Present,
|
||||
};
|
||||
case ActionTypes.HIDE_ERROR:
|
||||
return {
|
||||
...state,
|
||||
latestErrorDisplay: LatestErrorDisplay.Hidden,
|
||||
latestErrorDisplay: DisplayStatus.Hidden,
|
||||
};
|
||||
case ActionTypes.CLEAR_ERROR:
|
||||
return {
|
||||
...state,
|
||||
latestError: undefined,
|
||||
latestErrorDisplay: LatestErrorDisplay.Hidden,
|
||||
latestErrorDisplay: DisplayStatus.Hidden,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -7,6 +7,10 @@ export enum AsyncProcessState {
|
||||
SUCCESS = 'Success',
|
||||
FAILURE = 'Failure',
|
||||
}
|
||||
export enum DisplayStatus {
|
||||
Present,
|
||||
Hidden,
|
||||
}
|
||||
|
||||
export type FunctionType = (...args: any[]) => any;
|
||||
export type ActionCreatorsMapObject = ObjectMap<FunctionType>;
|
||||
|
||||
Reference in New Issue
Block a user