-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Schwartz10/buyTokens
Buy tokens
- Loading branch information
Showing
7 changed files
with
791 additions
and
252 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,60 @@ | ||
import React, {Component} from 'react' | ||
import {connect} from 'react-redux' | ||
import SelectField from 'material-ui/SelectField'; | ||
import MenuItem from 'material-ui/MenuItem'; | ||
import RaisedButton from 'material-ui/RaisedButton'; | ||
import { buyTokens } from '../store/user'; | ||
|
||
const Exchange = props => ( | ||
<div> | ||
<h1>Buy Tokens</h1> | ||
</div> | ||
) | ||
class Exchange extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {value: 1}; | ||
} | ||
|
||
handleChange = (event, index, value) => this.setState({value}); | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<h1>Buy Tokens</h1> | ||
<SelectField | ||
floatingLabelText="Coin Amount" | ||
value={this.state.value} | ||
onChange={this.handleChange} | ||
> | ||
<MenuItem value={1} primaryText="1" /> | ||
<MenuItem value={3} primaryText="3" /> | ||
<MenuItem value={5} primaryText="5" /> | ||
<MenuItem value={10} primaryText="10" /> | ||
<MenuItem value={25} primaryText="25" /> | ||
<MenuItem value={50} primaryText="50" /> | ||
</SelectField> | ||
<RaisedButton | ||
onClick={(e) => | ||
this.props.buyTokens(e, this.state.value, this.props.contract.buyTokens, this.props.accounts[0])} | ||
label="Buy Tokens" primary={true} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* CONTAINER | ||
*/ | ||
const mapState = (state) => { | ||
return { | ||
user: state.user, | ||
contract: state.contract | ||
contract: state.contract, | ||
accounts: state.accounts | ||
} | ||
} | ||
|
||
const mapDispatch = (dispatch) => { | ||
return {} | ||
return { | ||
buyTokens: function(e, amount, contractFunc, account){ | ||
e.preventDefault() | ||
return dispatch(buyTokens(amount, contractFunc, account)) | ||
} | ||
} | ||
} | ||
|
||
export default connect(mapState, mapDispatch)(Exchange) |
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