blob: 8225441f72b2317fe66278c64338f2eaa10ebee8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import { AssetBuyer, BuyQuote } from '@0x/asset-buyer';
import * as React from 'react';
import { BuyButton } from '../components/buy_button';
import { SecondaryButton } from '../components/secondary_button';
import { Flex } from '../components/ui/flex';
import { PlacingOrderButton } from '../components/placing_order_button';
import { ColorOption } from '../style/theme';
import { OrderProcessState, ZeroExInstantError } from '../types';
import { Button } from './ui/button';
import { Text } from './ui/text';
export interface BuyOrderStateButtonProps {
buyQuote?: BuyQuote;
buyOrderProcessingState: OrderProcessState;
assetBuyer?: AssetBuyer;
onViewTransaction: () => void;
onPendingValidation: (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;
onValidationFail: (buyQuote: BuyQuote, error: ZeroExInstantError) => 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.VALIDATING) {
return <PlacingOrderButton />;
}
return (
<BuyButton
buyQuote={props.buyQuote}
assetBuyer={props.assetBuyer}
onPendingValidation={props.onPendingValidation}
onSignatureDenied={props.onSignatureDenied}
onBuyProcessing={props.onBuyProcessing}
onBuySuccess={props.onBuySuccess}
onBuyFailure={props.onBuyFailure}
onValidationFail={props.onValidationFail}
/>
);
};
|