chore(instant): update OrderState enum to follow capitalization conventions

This commit is contained in:
Brandon Millman
2018-11-06 15:42:54 -08:00
parent ce4081bb18
commit c30dca6961
8 changed files with 43 additions and 43 deletions

View File

@@ -14,12 +14,12 @@ export const BuyOrderProgress: React.StatelessComponent<BuyOrderProgressProps> =
const { buyOrderState } = props;
if (
buyOrderState.processState === OrderProcessState.PROCESSING ||
buyOrderState.processState === OrderProcessState.SUCCESS ||
buyOrderState.processState === OrderProcessState.FAILURE
buyOrderState.processState === OrderProcessState.Processing ||
buyOrderState.processState === OrderProcessState.Success ||
buyOrderState.processState === OrderProcessState.Failure
) {
const progress = buyOrderState.progress;
const hasEnded = buyOrderState.processState !== OrderProcessState.PROCESSING;
const hasEnded = buyOrderState.processState !== OrderProcessState.Processing;
const expectedTimeMs = progress.expectedEndTimeUnix - progress.startTimeUnix;
return (
<Container padding="20px 20px 0px 20px" width="100%">

View File

@@ -28,7 +28,7 @@ export interface BuyOrderStateButtonProps {
}
export const BuyOrderStateButtons: React.StatelessComponent<BuyOrderStateButtonProps> = props => {
if (props.buyOrderProcessingState === OrderProcessState.FAILURE) {
if (props.buyOrderProcessingState === OrderProcessState.Failure) {
return (
<Flex justify="space-between">
<Button width="48%" onClick={props.onRetry}>
@@ -42,11 +42,11 @@ export const BuyOrderStateButtons: React.StatelessComponent<BuyOrderStateButtonP
</Flex>
);
} else if (
props.buyOrderProcessingState === OrderProcessState.SUCCESS ||
props.buyOrderProcessingState === OrderProcessState.PROCESSING
props.buyOrderProcessingState === OrderProcessState.Success ||
props.buyOrderProcessingState === OrderProcessState.Processing
) {
return <SecondaryButton onClick={props.onViewTransaction}>View Transaction</SecondaryButton>;
} else if (props.buyOrderProcessingState === OrderProcessState.VALIDATING) {
} else if (props.buyOrderProcessingState === OrderProcessState.Validating) {
return <PlacingOrderButton />;
}

View File

@@ -77,11 +77,11 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
private _renderIcon(): React.ReactNode {
const processState = this.props.buyOrderState.processState;
if (processState === OrderProcessState.FAILURE) {
if (processState === OrderProcessState.Failure) {
return <Icon icon="failed" width={ICON_WIDTH} height={ICON_HEIGHT} color={ICON_COLOR} />;
} else if (processState === OrderProcessState.PROCESSING) {
} else if (processState === OrderProcessState.Processing) {
return <Spinner widthPx={ICON_HEIGHT} heightPx={ICON_HEIGHT} />;
} else if (processState === OrderProcessState.SUCCESS) {
} else if (processState === OrderProcessState.Success) {
return <Icon icon="success" width={ICON_WIDTH} height={ICON_HEIGHT} color={ICON_COLOR} />;
}
return undefined;
@@ -89,11 +89,11 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
private _renderTopText(): React.ReactNode {
const processState = this.props.buyOrderState.processState;
if (processState === OrderProcessState.FAILURE) {
if (processState === OrderProcessState.Failure) {
return 'Order failed';
} else if (processState === OrderProcessState.PROCESSING) {
} else if (processState === OrderProcessState.Processing) {
return 'Processing Order...';
} else if (processState === OrderProcessState.SUCCESS) {
} else if (processState === OrderProcessState.Success) {
return 'Tokens received!';
}
@@ -101,7 +101,7 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
}
private _renderPlaceholderOrAmount(amountFunction: () => React.ReactNode): React.ReactNode {
if (this.props.quoteRequestState === AsyncProcessState.PENDING) {
if (this.props.quoteRequestState === AsyncProcessState.Pending) {
return <AmountPlaceholder isPulsating={true} color={PLACEHOLDER_COLOR} />;
}
if (_.isUndefined(this.props.selectedAssetAmount)) {

View File

@@ -22,7 +22,7 @@ const mapStateToProps = (state: State, _ownProps: LatestBuyQuoteOrderDetailsProp
// use the worst case quote info
buyQuoteInfo: oc(state).latestBuyQuote.worstCaseQuoteInfo(),
ethUsdPrice: state.ethUsdPrice,
isLoading: state.quoteRequestState === AsyncProcessState.PENDING,
isLoading: state.quoteRequestState === AsyncProcessState.Pending,
});
export const LatestBuyQuoteOrderDetails: React.ComponentClass<LatestBuyQuoteOrderDetailsProps> = connect(

View File

@@ -37,9 +37,9 @@ const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyOrderStateButt
onViewTransaction: () => {
if (
state.assetBuyer &&
(state.buyOrderState.processState === OrderProcessState.PROCESSING ||
state.buyOrderState.processState === OrderProcessState.SUCCESS ||
state.buyOrderState.processState === OrderProcessState.FAILURE)
(state.buyOrderState.processState === OrderProcessState.Processing ||
state.buyOrderState.processState === OrderProcessState.Success ||
state.buyOrderState.processState === OrderProcessState.Failure)
) {
const etherscanUrl = etherscanUtil.getEtherScanTxnAddressIfExists(
state.buyOrderState.txHash,

View File

@@ -52,7 +52,7 @@ type FinalProps = ConnectedProps & SelectedERC20AssetAmountInputProps;
const mapStateToProps = (state: State, _ownProps: SelectedERC20AssetAmountInputProps): ConnectedState => {
const processState = state.buyOrderState.processState;
const isEnabled = processState === OrderProcessState.NONE || processState === OrderProcessState.FAILURE;
const isEnabled = processState === OrderProcessState.None || processState === OrderProcessState.Failure;
const isDisabled = !isEnabled;
const selectedAsset =
!_.isUndefined(state.selectedAsset) && state.selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20

View File

@@ -39,12 +39,12 @@ export const INITIAL_STATE: State = {
selectedAssetAmount: undefined,
availableAssets: undefined,
assetMetaDataMap,
buyOrderState: { processState: OrderProcessState.NONE },
buyOrderState: { processState: OrderProcessState.None },
ethUsdPrice: undefined,
latestBuyQuote: undefined,
latestErrorMessage: undefined,
latestErrorDisplayStatus: DisplayStatus.Hidden,
quoteRequestState: AsyncProcessState.NONE,
quoteRequestState: AsyncProcessState.None,
affiliateInfo: undefined,
};
@@ -68,7 +68,7 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
return {
...state,
latestBuyQuote: newBuyQuoteIfExists,
quoteRequestState: AsyncProcessState.SUCCESS,
quoteRequestState: AsyncProcessState.Success,
};
} else {
return state;
@@ -78,23 +78,23 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
return {
...state,
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.PENDING,
quoteRequestState: AsyncProcessState.Pending,
};
case ActionTypes.SET_QUOTE_REQUEST_STATE_FAILURE:
return {
...state,
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.FAILURE,
quoteRequestState: AsyncProcessState.Failure,
};
case ActionTypes.SET_BUY_ORDER_STATE_NONE:
return {
...state,
buyOrderState: { processState: OrderProcessState.NONE },
buyOrderState: { processState: OrderProcessState.None },
};
case ActionTypes.SET_BUY_ORDER_STATE_VALIDATING:
return {
...state,
buyOrderState: { processState: OrderProcessState.VALIDATING },
buyOrderState: { processState: OrderProcessState.Validating },
};
case ActionTypes.SET_BUY_ORDER_STATE_PROCESSING:
const processingData = action.data;
@@ -102,7 +102,7 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
return {
...state,
buyOrderState: {
processState: OrderProcessState.PROCESSING,
processState: OrderProcessState.Processing,
txHash: processingData.txHash,
progress: {
startTimeUnix,
@@ -118,7 +118,7 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
return {
...state,
buyOrderState: {
processState: OrderProcessState.FAILURE,
processState: OrderProcessState.Failure,
txHash,
progress,
},
@@ -134,7 +134,7 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
return {
...state,
buyOrderState: {
processState: OrderProcessState.SUCCESS,
processState: OrderProcessState.Success,
txHash,
progress,
},
@@ -168,8 +168,8 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
return {
...state,
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.NONE,
buyOrderState: { processState: OrderProcessState.NONE },
quoteRequestState: AsyncProcessState.None,
buyOrderState: { processState: OrderProcessState.None },
selectedAssetAmount: undefined,
};
case ActionTypes.SET_AVAILABLE_ASSETS:

View File

@@ -3,18 +3,18 @@ import { AssetProxyId, ObjectMap } from '@0x/types';
// Reusable
export type Maybe<T> = T | undefined;
export enum AsyncProcessState {
NONE = 'None',
PENDING = 'Pending',
SUCCESS = 'Success',
FAILURE = 'Failure',
None = 'NONE',
Pending = 'PENDING',
Success = 'SUCCESS',
Failure = 'FAILURE',
}
export enum OrderProcessState {
NONE = 'None',
VALIDATING = 'Validating',
PROCESSING = 'Processing',
SUCCESS = 'Success',
FAILURE = 'Failure',
None = 'NONE',
Validating = 'VALIDATING',
Processing = 'PROCESSING',
Success = 'SUCCESS',
Failure = 'FAILURE',
}
export interface SimulatedProgress {
@@ -23,10 +23,10 @@ export interface SimulatedProgress {
}
interface OrderStatePreTx {
processState: OrderProcessState.NONE | OrderProcessState.VALIDATING;
processState: OrderProcessState.None | OrderProcessState.Validating;
}
interface OrderStatePostTx {
processState: OrderProcessState.PROCESSING | OrderProcessState.SUCCESS | OrderProcessState.FAILURE;
processState: OrderProcessState.Processing | OrderProcessState.Success | OrderProcessState.Failure;
txHash: string;
progress: SimulatedProgress;
}