import * as errorActions from '../actions/errors'; export interface ErrorState { isError: boolean; redirectURL: string; requestURL: string; error: any; } export const initialErrorState: ErrorState = { isError: false, redirectURL: null, requestURL: null, error: null }; export function ErrorsReducer(state = initialErrorState, action: errorActions.ErrorActions): ErrorState { switch (action.type) { case errorActions.TOGGLE_API_ERROR: { let isError: boolean = state.isError; const requestURL = action.requestURL; const redirectURL = action.redirectURL; const error = action.err; isError = !isError; return { ...state, isError, redirectURL, requestURL, error }; } default: { return state; } } }