aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers/selected_asset_progress.tsx
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-01 07:54:52 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-01 07:54:52 +0800
commit906909e33fe97d49196696c528c131c1a1c66f14 (patch)
tree90166c5e1729526ed8f72dfc7aebfd300c4dffdd /packages/instant/src/containers/selected_asset_progress.tsx
parentd192a7d466a6bda72ff69360454df547958601e4 (diff)
downloaddexon-0x-contracts-906909e33fe97d49196696c528c131c1a1c66f14.tar.gz
dexon-0x-contracts-906909e33fe97d49196696c528c131c1a1c66f14.tar.zst
dexon-0x-contracts-906909e33fe97d49196696c528c131c1a1c66f14.zip
Rename to SelectedAssetProgress
Diffstat (limited to 'packages/instant/src/containers/selected_asset_progress.tsx')
-rw-r--r--packages/instant/src/containers/selected_asset_progress.tsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/instant/src/containers/selected_asset_progress.tsx b/packages/instant/src/containers/selected_asset_progress.tsx
new file mode 100644
index 000000000..afbb45dac
--- /dev/null
+++ b/packages/instant/src/containers/selected_asset_progress.tsx
@@ -0,0 +1,49 @@
+import * as React from 'react';
+
+import { connect } from 'react-redux';
+
+import { TimedProgressBar } from '../components/timed_progress_bar';
+
+import { TimeCounter } from '../components/time_counter';
+import { Container } from '../components/ui';
+import { State } from '../redux/reducer';
+import { OrderProcessState, OrderState, SimulatedProgress } from '../types';
+
+interface SelectedAssetProgressComponentProps {
+ buyOrderState: OrderState;
+}
+// TODO: rename this component and move to seperate file, and get props using mapStateToProps
+export const SelectedAssetSimulatedProgressComponent: React.StatelessComponent<
+ SelectedAssetProgressComponentProps
+> = props => {
+ const { buyOrderState } = props;
+
+ if (
+ buyOrderState.processState === OrderProcessState.PROCESSING ||
+ buyOrderState.processState === OrderProcessState.SUCCESS ||
+ buyOrderState.processState === OrderProcessState.FAILURE
+ ) {
+ const progress = buyOrderState.progress;
+ const ended = buyOrderState.processState !== OrderProcessState.PROCESSING;
+ const expectedTimeMs = progress.expectedEndTimeUnix - progress.startTimeUnix;
+ return (
+ <Container padding="20px 20px 0px 20px" width="100%">
+ <Container marginBottom="5px">
+ <TimeCounter estimatedTimeMs={expectedTimeMs} ended={ended} key={progress.startTimeUnix} />
+ </Container>
+ <TimedProgressBar expectedTimeMs={expectedTimeMs} ended={ended} key={progress.startTimeUnix} />
+ </Container>
+ );
+ }
+
+ return null;
+};
+
+interface ConnectedState {
+ buyOrderState: OrderState;
+ simulatedProgress?: SimulatedProgress;
+}
+const mapStateToProps = (state: State, _ownProps: {}): ConnectedState => ({
+ buyOrderState: state.buyOrderState,
+});
+export const SelectedAssetProgress = connect(mapStateToProps)(SelectedAssetSimulatedProgressComponent);