-
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 #3 from Schwartz10/postPhotos
Post photos
- Loading branch information
Showing
13 changed files
with
1,696 additions
and
316 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 |
---|---|---|
|
@@ -10,5 +10,3 @@ | |
c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3 | ||
|
||
http://127.0.0.1:7545 | ||
|
||
|
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,81 @@ | ||
import React, { Component } from 'react' | ||
import {connect} from 'react-redux' | ||
import { Link } from 'react-router-dom'; | ||
import TextField from 'material-ui/TextField'; | ||
import Post from './Post'; | ||
import RaisedButton from 'material-ui/RaisedButton'; | ||
import { post } from '../store/posts'; | ||
|
||
class CreatePost extends Component { | ||
constructor(props){ | ||
super(props); | ||
this.state = { canPost: this.props.user.coinBalance >= 5, | ||
postUrl: "" } | ||
} | ||
|
||
handleChange = (event) => { | ||
this.setState({ | ||
postUrl: event.target.value, | ||
}); | ||
}; | ||
|
||
render(){ | ||
return( | ||
<div> | ||
{this.props.user ? | ||
<div> | ||
<h1>Create Your Post {this.props.user.name}</h1> | ||
<h3>You currently have {this.props.user.coinBalance} Tokens <br /></h3> | ||
<TextField | ||
value={this.props.postUrl} | ||
hintText={!this.state.postUrl.length && "Enter Post URL"} | ||
onChange={this.handleChange} | ||
/><br /> | ||
{ this.state.postUrl.length && | ||
<div> | ||
<h3>Post Preview:</h3> | ||
<Post | ||
username={this.props.user.name} | ||
tokenPot={5} | ||
postUrl={this.state.postUrl} | ||
isPreview={true} | ||
/> | ||
<RaisedButton | ||
onClick={e => | ||
this.props.post(e, this.state.postUrl, this.props.contract.createPost, this.props.accounts[0])} | ||
label="Create Post" primary={true} | ||
/> | ||
</div> | ||
} | ||
</div> | ||
: | ||
<div> | ||
<h1>Create your account first!</h1> | ||
<Link to='/profile'>Create Accout</Link> | ||
</div> | ||
} | ||
</div> ) | ||
} | ||
} | ||
|
||
/** | ||
* CONTAINER | ||
*/ | ||
const mapState = (state) => { | ||
return { | ||
user: state.user, | ||
contract: state.contract, | ||
accounts: state.accounts | ||
} | ||
} | ||
|
||
const mapDispatch = (dispatch) => { | ||
return { | ||
post: function(e, postUrl, contractFunc, account){ | ||
e.preventDefault(); | ||
return dispatch(post(postUrl, contractFunc, account)); | ||
} | ||
} | ||
} | ||
|
||
export default connect(mapState, mapDispatch)(CreatePost) |
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,17 @@ | ||
import React, {Component} from 'react' | ||
import Post from './Post' | ||
|
||
export default class Explore extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
render(){ | ||
return( | ||
<div> | ||
<h1>Explore</h1> | ||
</div> | ||
) | ||
} | ||
} |
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,31 @@ | ||
import React, {Component} from 'react'; | ||
import {connect} from 'react-redux' | ||
import {Card, CardActions, CardHeader, CardMedia, CardTitle } from 'material-ui/Card'; | ||
import FlatButton from 'material-ui/FlatButton'; | ||
|
||
const cardStyle = { | ||
width: '30vw' | ||
} | ||
|
||
const Post = props => ( | ||
<Card style={cardStyle}> | ||
<CardHeader | ||
title={props.username} | ||
/> | ||
<CardMedia | ||
overlay={<CardTitle title={'Token pot: ' + props.tokenPot} />} | ||
> | ||
<img src={props.postUrl} alt="" /> | ||
</CardMedia> | ||
{!props.isPreview && | ||
<div> | ||
<CardTitle title="Leave a Caption"/> | ||
<CardActions> | ||
<FlatButton label="Submit" /> | ||
</CardActions> | ||
</div> | ||
} | ||
</Card> | ||
) | ||
|
||
export default Post; |
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,42 @@ | ||
/** | ||
* INITIAL STATE | ||
*/ | ||
const defaultPosts = [] | ||
|
||
/** | ||
* ACTION TYPES | ||
*/ | ||
const CREATE_POST = 'CREATE_POST'; | ||
|
||
/** | ||
* ACTION CREATORS | ||
*/ | ||
const createPost = post => ({type: CREATE_POST, post}) | ||
|
||
/** | ||
* THUNK CREATORS | ||
*/ | ||
|
||
export const post = (url, contractFunc, account) => | ||
dispatch => | ||
contractFunc(url, {from: account}) | ||
.then(res => { | ||
let newPost = {} | ||
newPost[account] = res.logs[0].args.url; | ||
return dispatch(createPost(newPost)); | ||
}) | ||
.catch(err => console.log(err)); | ||
|
||
/** | ||
* REDUCER | ||
*/ | ||
export default function (state = defaultPosts, action) { | ||
switch (action.type) { | ||
case CREATE_POST: | ||
let posts = state.slice() | ||
posts.push(action.post) | ||
return posts; | ||
default: | ||
return state | ||
} | ||
} |
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