From 4f5ab1a72d33dc6a7516d7b1d51f1aa15752a6b8 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 26 Oct 2018 15:32:04 -0700 Subject: Refactor error handling such that errorMessage lives on the top level state --- packages/instant/src/redux/reducer.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'packages/instant/src/redux/reducer.ts') diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts index d7e5bdfb5..3884eeea9 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -28,8 +28,8 @@ export interface State { ethUsdPrice?: BigNumber; latestBuyQuote?: BuyQuote; quoteRequestState: AsyncProcessState; - latestError?: any; - latestErrorDisplay: DisplayStatus; + latestErrorMessage?: string; + latestErrorDisplayStatus: DisplayStatus; } export const INITIAL_STATE: State = { @@ -39,8 +39,8 @@ export const INITIAL_STATE: State = { buyOrderState: { processState: OrderProcessState.NONE }, ethUsdPrice: undefined, latestBuyQuote: undefined, - latestError: undefined, - latestErrorDisplay: DisplayStatus.Hidden, + latestErrorMessage: undefined, + latestErrorDisplayStatus: DisplayStatus.Hidden, quoteRequestState: AsyncProcessState.NONE, }; @@ -79,22 +79,22 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State => ...state, buyOrderState: action.data, }; - case ActionTypes.SET_ERROR: + case ActionTypes.SET_ERROR_MESSAGE: return { ...state, - latestError: action.data, - latestErrorDisplay: DisplayStatus.Present, + latestErrorMessage: action.data, + latestErrorDisplayStatus: DisplayStatus.Present, }; case ActionTypes.HIDE_ERROR: return { ...state, - latestErrorDisplay: DisplayStatus.Hidden, + latestErrorDisplayStatus: DisplayStatus.Hidden, }; case ActionTypes.CLEAR_ERROR: return { ...state, - latestError: undefined, - latestErrorDisplay: DisplayStatus.Hidden, + latestErrorMessage: undefined, + latestErrorDisplayStatus: DisplayStatus.Hidden, }; case ActionTypes.UPDATE_SELECTED_ASSET: const newSelectedAssetData = action.data; -- cgit