aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-20 04:51:57 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-20 04:51:57 +0800
commit6c79a858dff2766917ee3a4b5d4f623b66dadd17 (patch)
tree80ed81159418eaa9f57deff046d4376a5cc349ae /packages/instant
parent17b282b1d743c83a4a4378eb71df098949569bdd (diff)
downloaddexon-sol-tools-6c79a858dff2766917ee3a4b5d4f623b66dadd17.tar
dexon-sol-tools-6c79a858dff2766917ee3a4b5d4f623b66dadd17.tar.gz
dexon-sol-tools-6c79a858dff2766917ee3a4b5d4f623b66dadd17.tar.bz2
dexon-sol-tools-6c79a858dff2766917ee3a4b5d4f623b66dadd17.tar.lz
dexon-sol-tools-6c79a858dff2766917ee3a4b5d4f623b66dadd17.tar.xz
dexon-sol-tools-6c79a858dff2766917ee3a4b5d4f623b66dadd17.tar.zst
dexon-sol-tools-6c79a858dff2766917ee3a4b5d4f623b66dadd17.zip
WIP: clear buy quote working
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/components/asset_button.tsx10
-rw-r--r--packages/instant/src/containers/selected_asset_buy_button.ts2
-rw-r--r--packages/instant/src/redux/actions.ts2
-rw-r--r--packages/instant/src/redux/reducer.ts8
4 files changed, 15 insertions, 7 deletions
diff --git a/packages/instant/src/components/asset_button.tsx b/packages/instant/src/components/asset_button.tsx
index 84a27303d..4ae7a2704 100644
--- a/packages/instant/src/components/asset_button.tsx
+++ b/packages/instant/src/components/asset_button.tsx
@@ -9,6 +9,7 @@ import { BuyButton } from './buy_button';
import { RetryButton } from './retry_button';
import { Container } from './ui';
+// TODO: split into sepearte components? getting really big..
interface AssetButtonProps {
assetBuyer?: AssetBuyer;
buyQuote?: BuyQuote;
@@ -16,6 +17,7 @@ interface AssetButtonProps {
onBuyClick: (buyQuote: BuyQuote) => void;
onBuySuccess: (buyQuote: BuyQuote) => void;
onBuyFailure: (buyQuote: BuyQuote) => void;
+ onRetryClick: () => void;
}
export class AssetButton extends React.Component<AssetButtonProps, {}> {
@@ -30,13 +32,7 @@ export class AssetButton extends React.Component<AssetButtonProps, {}> {
// TODO: figure out why buyOrderState is undefined in beginning, get rid of default
switch (this.props.buyOrderState) {
case AsyncProcessState.FAILURE:
- return (
- <RetryButton
- onClick={() => {
- console.log('try again');
- }}
- />
- );
+ return <RetryButton onClick={this.props.onRetryClick} />;
case AsyncProcessState.SUCCESS:
return <div />;
default:
diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts
index a5fa0aa8e..41d196b03 100644
--- a/packages/instant/src/containers/selected_asset_buy_button.ts
+++ b/packages/instant/src/containers/selected_asset_buy_button.ts
@@ -24,6 +24,7 @@ interface ConnectedDispatch {
onBuyClick: (buyQuote: BuyQuote) => void;
onBuySuccess: (buyQuote: BuyQuote) => void;
onBuyFailure: (buyQuote: BuyQuote) => void;
+ onRetryClick: () => void;
}
const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps): ConnectedState => ({
@@ -36,6 +37,7 @@ const mapDispatchToProps = (dispatch: Dispatch<Action>, ownProps: SelectedAssetB
onBuyClick: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.PENDING)),
onBuySuccess: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.SUCCESS)),
onBuyFailure: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.FAILURE)),
+ onRetryClick: () => dispatch(actions.clearBuyQuoteAndSelectedAssetAmount()),
});
export const SelectedAssetBuyButton: React.ComponentClass<SelectedAssetBuyButtonProps> = connect(
diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts
index bc75ce66c..d6388d77e 100644
--- a/packages/instant/src/redux/actions.ts
+++ b/packages/instant/src/redux/actions.ts
@@ -31,6 +31,7 @@ export enum ActionTypes {
SET_ERROR = 'SET_ERROR',
HIDE_ERROR = 'HIDE_ERROR',
CLEAR_ERROR = 'CLEAR_ERROR',
+ CLEAR_BUY_QUOTE_AND_SELECTED_ASSET_AMOUNT = 'CLEAR_BUY_QUOTE_AND_SELECTED_ASSET_AMOUNT',
}
export const actions = {
@@ -45,4 +46,5 @@ export const actions = {
setError: (error?: any) => createAction(ActionTypes.SET_ERROR, error),
hideError: () => createAction(ActionTypes.HIDE_ERROR),
clearError: () => createAction(ActionTypes.CLEAR_ERROR),
+ clearBuyQuoteAndSelectedAssetAmount: () => createAction(ActionTypes.CLEAR_BUY_QUOTE_AND_SELECTED_ASSET_AMOUNT),
};
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 657bd0e40..10e56f152 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -99,6 +99,14 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
...state,
selectedAsset: newSelectedAsset,
};
+ case ActionTypes.CLEAR_BUY_QUOTE_AND_SELECTED_ASSET_AMOUNT:
+ return {
+ ...state,
+ latestBuyQuote: undefined,
+ quoteState: AsyncProcessState.NONE,
+ buyOrderState: AsyncProcessState.NONE,
+ selectedAssetAmount: undefined,
+ };
default:
return state;
}