diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-13 02:00:36 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-13 02:00:36 +0800 |
commit | f3391e1250767eb9ef7a74f78eded38fa3c94586 (patch) | |
tree | e25eeb3652227ea68f5b77db82755765298cb22a /packages/instant/src/containers/selected_asset_amount_input.ts | |
parent | 09c5ae4e65f8fddd4504be041f27f9107d12df7d (diff) | |
download | dexon-0x-contracts-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar.gz dexon-0x-contracts-f3391e1250767eb9ef7a74f78eded38fa3c94586.tar.zst dexon-0x-contracts-f3391e1250767eb9ef7a74f78eded38fa3c94586.zip |
feat: make redux actions type-sage
Diffstat (limited to 'packages/instant/src/containers/selected_asset_amount_input.ts')
-rw-r--r-- | packages/instant/src/containers/selected_asset_amount_input.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts index fa675b385..9e3063ecc 100644 --- a/packages/instant/src/containers/selected_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_asset_amount_input.ts @@ -6,9 +6,10 @@ import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { zrxContractAddress, zrxDecimals } from '../constants'; +import { Action, actions } from '../redux/actions'; import { State } from '../redux/reducer'; import { ColorOption } from '../style/theme'; -import { Action, ActionTypes, AsyncProcessState } from '../types'; +import { AsyncProcessState } from '../types'; import { assetBuyer } from '../util/asset_buyer'; import { AmountInput } from '../components/amount_input'; @@ -38,7 +39,7 @@ const updateBuyQuote = async (dispatch: Dispatch<Action>, assetAmount?: BigNumbe const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals); const newBuyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(zrxContractAddress, baseUnitValue); // invalidate the last buy quote. - dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: newBuyQuote }); + dispatch(actions.updateLatestBuyQuote(newBuyQuote)); }; const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true }); @@ -46,11 +47,12 @@ const debouncedUpdateBuyQuote = _.debounce(updateBuyQuote, 200, { trailing: true const mapDispatchToProps = (dispatch: Dispatch<Action>): ConnectedDispatch => ({ onChange: async value => { // Update the input - dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, data: value }); + dispatch(actions.updateSelectedAssetAmount(value)); // invalidate the last buy quote. - dispatch({ type: ActionTypes.UPDATE_LATEST_BUY_QUOTE, data: undefined }); + dispatch(actions.updateLatestBuyQuote(undefined)); // reset our buy state - dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, data: AsyncProcessState.NONE }); + dispatch(actions.updateSelectedAssetBuyState(AsyncProcessState.NONE)); + // tslint:disable-next-line:no-floating-promises debouncedUpdateBuyQuote(dispatch, value); }, }); |