-
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 #8 from Schwartz10/likingPhoto
Liking photo
- Loading branch information
Showing
13 changed files
with
2,074 additions
and
1,239 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { Component } from 'react' | ||
import {connect} from 'react-redux' | ||
import RaisedButton from 'material-ui/RaisedButton'; | ||
import { likePost } from '../store/posts'; | ||
|
||
class LikePhoto extends Component { | ||
constructor(props){ | ||
super(props); | ||
} | ||
|
||
render(){ | ||
return( | ||
<div> | ||
<RaisedButton label="like" onClick={e => this.props.like(e, this.props.postUrl, this.props.postAddress, this.props.contract.likePost, this.props.accounts[0])}/> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* CONTAINER | ||
*/ | ||
const mapState = (state) => { | ||
return { | ||
user: state.user, | ||
contract: state.contract, | ||
accounts: state.accounts, | ||
posts: state.posts | ||
} | ||
} | ||
|
||
const mapDispatch = (dispatch) => { | ||
return { | ||
like: function(e, postUrl, postAddress, contractFunc, account){ | ||
e.preventDefault(); | ||
return dispatch(likePost(postUrl, postAddress, contractFunc, account)); | ||
} | ||
} | ||
} | ||
|
||
export default connect(mapState, mapDispatch)(LikePhoto) |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const likedPostHelper = {} | ||
|
||
likedPostHelper.updateUser = function(state, newPostInfo) { | ||
let newState = Object.assign({}, state); | ||
|
||
if (newState.address === newPostInfo.liker) { | ||
newState.coinBalance = newPostInfo.likerCoinbalance | ||
} | ||
|
||
return newState; | ||
} | ||
|
||
likedPostHelper.updatePost = function(state, newPostInfo) { | ||
let newState = state.slice(); | ||
|
||
for (let i = 0; i < newState.length; i++) { | ||
if (newState[i].address === newPostInfo.poster){ | ||
newState[i].tokenPot = newPostInfo.lotteryAmount; | ||
} | ||
} | ||
|
||
return newState; | ||
} | ||
|
||
module.exports = likedPostHelper; |