Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Commit

Permalink
pass through send stage
Browse files Browse the repository at this point in the history
  • Loading branch information
micimize committed Mar 9, 2018
1 parent 2f37ef5 commit 0574af7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/assets/Asset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class Asset extends React.Component<Asset.Props, {}> {

}
render() {
let { asset, sync, wallet, actions: { send } } = this.props
let { asset, sync, wallet, actions: { send }, sendAssetsStage } = this.props
return (
<Wrapper>
<View style={this.props.style.main}>
{ isBalance(asset) && [
<Card key='asset' styleNames='asset' style={{ width: '100%' }}>
<Balance styleNames='focused header' {...asset} />
</Card>,
<SendAsset key='send' {...{ asset, wallet, send }} />
<SendAsset key='send' {...{ asset, wallet, send, stage: sendAssetsStage }} />
]}
<DeckCard sync={sync} style={{ width: '100%' }} item={asset.deck} />
</View>
Expand All @@ -67,6 +67,7 @@ namespace Asset {
export type Props = {
asset: Summary.Balance | { deck: Deck }
sync: SyncButton.Logic
sendAssetsStage: string | undefined
actions: {
send: SendAsset.Props['send']
}
Expand Down
4 changes: 2 additions & 2 deletions src/assets/AssetContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export default connect(
({ wallet: { wallet }, assets: { routineStages, decks, balances } }: RootState, { match }: RouterProps): MappedProps => {
let balance = (balances || []).filter(b => b.deck.id === match.params.id)[0]
if(balance){
return { asset: balance, wallet, stage: routineStages.syncAsset }
return { asset: balance, wallet, stage: routineStages.syncAsset, sendAssetsStage: routineStages.sendAssets }
}
let deck = (decks || []).filter(deck => deck.id === match.params.id)[0]
if(deck){
return { asset: { deck }, wallet, stage: routineStages.syncAsset }
return { asset: { deck }, wallet, stage: routineStages.syncAsset, sendAssetsStage: routineStages.sendAssets }
}
return { redirect: true as true }
},
Expand Down
28 changes: 16 additions & 12 deletions src/assets/SendAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ class AddRecipient extends React.Component<{ decimals: number, add: (r: Recipien
}
}

function SendButton(props: { stage: undefined | string, DEFAULT: string, disabled: boolean, onPress: () => any }){
return (
<RoutineButton styleNames='block'
icons={{ DEFAULT: 'send' }}
STARTED='Sending'
DONE='Sent!'
FAILED='Invalid Transaction'
{...props} />
)
}

class SendAsset extends React.Component<SendAsset.Props, SendAsset.Data> {
state: SendAsset.Data = {
amountsMap: {},
Expand All @@ -163,18 +174,6 @@ class SendAsset extends React.Component<SendAsset.Props, SendAsset.Data> {
let transactionType = type === 'RECEIVED' ? 'Send' : 'Issue'
let canSendAmount = (transactionType === 'Issue' || (totalAmount < balance))

let SendButton = (props: { onPress: () => any }) =>
<RoutineButton styleNames='block'
disabled={(!isFilled(this.state)) || (!canSendAmount) || !Deck.isFull(this.props.asset.deck)}
icons={{ DEFAULT: 'send' }}
stage={this.props.stage}
DEFAULT={!canSendAmount ? 'Insufficient Funds!' : `${transactionType} Asset`}
STARTED='Sending'
DONE='Sent!'
FAILED='Invalid Transaction'
{...props} />


let remove = (address: string) => () => {
let { [address]: _, ...amountsMap } = this.state.amountsMap
this.setState({ amountsMap })
Expand Down Expand Up @@ -210,6 +209,11 @@ class SendAsset extends React.Component<SendAsset.Props, SendAsset.Data> {
actionProp='onPress'
action={this.send}
Component={SendButton}
componentProps={{
disabled: (!isFilled(this.state)) || (!canSendAmount) || !Deck.isFull(this.props.asset.deck),
stage: this.props.stage,
DEFAULT: !canSendAmount ? 'Insufficient Funds!' : `${transactionType} Asset`,
}}
/>
</Body>
</CardItem>
Expand Down

0 comments on commit 0574af7

Please sign in to comment.