From 15f20cc18e45d2971be7274bc3c0be36b02091c8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 3 Oct 2018 14:28:07 -0700 Subject: Add redux to 0x instant --- packages/instant/src/redux/reducer.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/instant/src/redux/reducer.ts (limited to 'packages/instant/src/redux/reducer.ts') diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts new file mode 100644 index 000000000..7efe8aeb0 --- /dev/null +++ b/packages/instant/src/redux/reducer.ts @@ -0,0 +1,23 @@ +import * as _ from 'lodash'; + +import { Action, ActionTypes } from '../types'; + +export interface State { + ethUsdPrice?: string; +} + +export const INITIAL_STATE: State = { + ethUsdPrice: undefined, +}; + +export function reducer(state: State = INITIAL_STATE, action: Action): State { + switch (action.type) { + case ActionTypes.UPDATE_ETH_USD_PRICE: + return { + ...state, + ethUsdPrice: action.data, + }; + default: + return state; + } +} -- cgit v1.2.3 From ba2ba628e815c996582c6ead81f657a14a00abd0 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 4 Oct 2018 15:02:06 -0700 Subject: Fix linting problems --- packages/instant/src/redux/reducer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 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 7efe8aeb0..e4578d620 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -10,7 +10,7 @@ export const INITIAL_STATE: State = { ethUsdPrice: undefined, }; -export function reducer(state: State = INITIAL_STATE, action: Action): State { +export const reducer = (state: State = INITIAL_STATE, action: Action): State => { switch (action.type) { case ActionTypes.UPDATE_ETH_USD_PRICE: return { @@ -20,4 +20,4 @@ export function reducer(state: State = INITIAL_STATE, action: Action): State { default: return state; } -} +}; -- cgit v1.2.3 From 1eb8d17ce36274093583069aab0025768a4a91ce Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 4 Oct 2018 19:24:10 -0700 Subject: Create SelectedAssetInputAmount --- packages/instant/src/redux/reducer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (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 e4578d620..5026895ae 100644 --- a/packages/instant/src/redux/reducer.ts +++ b/packages/instant/src/redux/reducer.ts @@ -1,13 +1,16 @@ +import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { Action, ActionTypes } from '../types'; export interface State { ethUsdPrice?: string; + selectedAssetAmount?: BigNumber; } export const INITIAL_STATE: State = { ethUsdPrice: undefined, + selectedAssetAmount: undefined, }; export const reducer = (state: State = INITIAL_STATE, action: Action): State => { @@ -17,6 +20,11 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State => ...state, ethUsdPrice: action.data, }; + case ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT: + return { + ...state, + selectedAssetAmount: action.data, + }; default: return state; } -- cgit v1.2.3