aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/buy_order_state_buttons.tsx
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-27 03:53:04 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-27 03:53:04 +0800
commit7fa1f25e065c737e7589b57fb0249db5c1ceb4fb (patch)
tree21d88ce6c441ddcb62eed2a547753f7c69e6121e /packages/instant/src/components/buy_order_state_buttons.tsx
parent68182fb6c41256f9886c7aa0269746b3a9ac632f (diff)
downloaddexon-sol-tools-7fa1f25e065c737e7589b57fb0249db5c1ceb4fb.tar
dexon-sol-tools-7fa1f25e065c737e7589b57fb0249db5c1ceb4fb.tar.gz
dexon-sol-tools-7fa1f25e065c737e7589b57fb0249db5c1ceb4fb.tar.bz2
dexon-sol-tools-7fa1f25e065c737e7589b57fb0249db5c1ceb4fb.tar.lz
dexon-sol-tools-7fa1f25e065c737e7589b57fb0249db5c1ceb4fb.tar.xz
dexon-sol-tools-7fa1f25e065c737e7589b57fb0249db5c1ceb4fb.tar.zst
dexon-sol-tools-7fa1f25e065c737e7589b57fb0249db5c1ceb4fb.zip
buy order state button -> buy order state buttons
Diffstat (limited to 'packages/instant/src/components/buy_order_state_buttons.tsx')
-rw-r--r--packages/instant/src/components/buy_order_state_buttons.tsx63
1 files changed, 63 insertions, 0 deletions
diff --git a/packages/instant/src/components/buy_order_state_buttons.tsx b/packages/instant/src/components/buy_order_state_buttons.tsx
new file mode 100644
index 000000000..2330f84f9
--- /dev/null
+++ b/packages/instant/src/components/buy_order_state_buttons.tsx
@@ -0,0 +1,63 @@
+import { AssetBuyer, BuyQuote } from '@0x/asset-buyer';
+import * as React from 'react';
+
+import { Flex } from '../components/ui/flex';
+import { SecondaryButton } from '../components/secondary_button';
+import { BuyButton } from '../components/buy_button';
+
+import { PlacingOrderButton } from '../components/placing_order_button';
+import { ColorOption } from '../style/theme';
+import { OrderProcessState } from '../types';
+
+import { Button } from './ui/button';
+import { Text } from './ui/text';
+
+export interface BuyOrderStateButtonProps {
+ buyQuote?: BuyQuote;
+ buyOrderProcessingState: OrderProcessState;
+ assetBuyer?: AssetBuyer;
+ onViewTransaction: () => void;
+ onAwaitingSignature: (buyQuote: BuyQuote) => void;
+ onSignatureDenied: (buyQuote: BuyQuote, error: Error) => void;
+ onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => void;
+ onBuySuccess: (buyQuote: BuyQuote, txHash: string) => void;
+ onBuyFailure: (buyQuote: BuyQuote, txHash: string) => void;
+ onRetry: () => void;
+}
+
+// TODO: rename to buttons
+export const BuyOrderStateButtons: React.StatelessComponent<BuyOrderStateButtonProps> = props => {
+ if (props.buyOrderProcessingState === OrderProcessState.FAILURE) {
+ return (
+ <Flex justify="space-between">
+ <Button width="48%" onClick={props.onRetry}>
+ <Text fontColor={ColorOption.white} fontWeight={600} fontSize="16px">
+ Back
+ </Text>
+ </Button>
+ <SecondaryButton width="48%" onClick={props.onViewTransaction}>
+ Details
+ </SecondaryButton>
+ </Flex>
+ );
+ } else if (
+ props.buyOrderProcessingState === OrderProcessState.SUCCESS ||
+ props.buyOrderProcessingState === OrderProcessState.PROCESSING
+ ) {
+ return <SecondaryButton onClick={props.onViewTransaction}>View Transaction</SecondaryButton>;
+ } else if (props.buyOrderProcessingState === OrderProcessState.AWAITING_SIGNATURE) {
+ return <PlacingOrderButton />;
+ }
+
+ return (
+ <BuyButton
+ buyQuote={props.buyQuote}
+ assetBuyer={props.assetBuyer}
+ onAwaitingSignature={props.onAwaitingSignature}
+ onSignatureDenied={props.onSignatureDenied}
+ onBuyProcessing={props.onBuyProcessing}
+ onBuySuccess={props.onBuySuccess}
+ onBuyFailure={props.onBuyFailure}
+ />
+ );
+};