-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(simple buy): implement cancel order
- Loading branch information
Philip London
committed
Mar 25, 2020
1 parent
f3a0484
commit b8d0f0e
Showing
15 changed files
with
224 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/blockchain-wallet-v4-frontend/src/data/components/simpleBuy/actionTypes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CancelOrder/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { actions } from 'data' | ||
import { bindActionCreators, compose, Dispatch } from 'redux' | ||
import { connect } from 'react-redux' | ||
import { RootState } from 'data/rootReducer' | ||
import { SBOrderType } from 'core/types' | ||
import React, { PureComponent } from 'react' | ||
import Template from './template' | ||
|
||
export type OwnProps = { | ||
handleClose: () => void | ||
order: SBOrderType | ||
} | ||
export type LinkDispatchPropsType = { | ||
simpleBuyActions: typeof actions.components.simpleBuy | ||
} | ||
type LinkStatePropsType = {} | ||
type Props = OwnProps & LinkDispatchPropsType & LinkStatePropsType | ||
type State = {} | ||
|
||
class CancelOrder extends PureComponent<Props, State> { | ||
state = {} | ||
|
||
handleSubmit = () => { | ||
this.props.simpleBuyActions.cancelSBOrder(this.props.order) | ||
} | ||
|
||
render () { | ||
return <Template {...this.props} onSubmit={this.handleSubmit} /> | ||
} | ||
} | ||
|
||
const mapStateToProps = (state: RootState): LinkStatePropsType => ({}) | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch): LinkDispatchPropsType => ({ | ||
simpleBuyActions: bindActionCreators(actions.components.simpleBuy, dispatch) | ||
}) | ||
|
||
const enhance = compose( | ||
connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
) | ||
) | ||
|
||
export default enhance(CancelOrder) |
111 changes: 111 additions & 0 deletions
111
packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CancelOrder/template.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { Button, HeartbeatLoader, Icon, Text } from 'blockchain-info-components' | ||
import { ErrorCartridge } from 'components/Cartridge' | ||
import { FlyoutWrapper } from 'components/Flyout' | ||
import { Form } from 'components/Form' | ||
import { FormattedMessage } from 'react-intl' | ||
import { InjectedFormProps, reduxForm } from 'redux-form' | ||
import { LinkDispatchPropsType, OwnProps } from '.' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
const Wrapper = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
` | ||
const CustomForm = styled(Form)` | ||
text-align: center; | ||
` | ||
|
||
type Props = OwnProps & LinkDispatchPropsType | ||
|
||
const Template: React.FC<InjectedFormProps<{}, Props> & Props> = props => { | ||
return ( | ||
<Wrapper> | ||
<FlyoutWrapper> | ||
<CustomForm onSubmit={props.handleSubmit}> | ||
<Icon | ||
name='alert-filled' | ||
color='orange400' | ||
size='52px' | ||
style={{ display: 'block' }} | ||
/> | ||
<Text | ||
color='grey800' | ||
size='24px' | ||
weight={600} | ||
style={{ marginTop: '32px' }} | ||
> | ||
<FormattedMessage | ||
id='modals.simplebuy.cancelorder.areyousure' | ||
defaultMessage='Are you sure?' | ||
/> | ||
</Text> | ||
<Text | ||
color='grey600' | ||
weight={500} | ||
size='16px' | ||
lineHeight='150%' | ||
style={{ marginTop: '8px', marginBottom: '48px' }} | ||
> | ||
<FormattedMessage | ||
id='modals.simplebuy.cancelorder.outcome' | ||
defaultMessage='Cancelling this {pair} Buy will remove your order. You can always create a new order from the menu if you cancel now.' | ||
values={{ | ||
pair: props.order.pair | ||
}} | ||
/> | ||
</Text> | ||
{props.error && ( | ||
<div style={{ marginBottom: '16px' }}> | ||
<ErrorCartridge>Error: {props.error}</ErrorCartridge> | ||
</div> | ||
)} | ||
<Button | ||
fullwidth | ||
size='16px' | ||
height='48px' | ||
nature='light' | ||
data-e2e='cancelSBOrder' | ||
disabled={props.submitting} | ||
type='submit' | ||
> | ||
{props.submitting ? ( | ||
<HeartbeatLoader color='blue100' height='20px' width='20px' /> | ||
) : ( | ||
<FormattedMessage | ||
id='modals.simplebuy.cancelorder.cancel' | ||
defaultMessage='Yes. Cancel Order' | ||
/> | ||
)} | ||
</Button> | ||
<Button | ||
fullwidth | ||
size='16px' | ||
height='48px' | ||
nature='primary' | ||
data-e2e='cancelSBOrder' | ||
disabled={props.submitting} | ||
onClick={() => | ||
props.simpleBuyActions.setStep({ | ||
step: 'ORDER_SUMMARY', | ||
order: props.order | ||
}) | ||
} | ||
style={{ marginTop: '16px' }} | ||
type='button' | ||
> | ||
<FormattedMessage | ||
id='modals.simplebuy.cancelorder.goback' | ||
defaultMessage='No. Go Back' | ||
/> | ||
</Button> | ||
</CustomForm> | ||
</FlyoutWrapper> | ||
</Wrapper> | ||
) | ||
} | ||
|
||
export default reduxForm<{}, Props>({ form: 'cancelSBOrderForm' })(Template) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters