1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-28 15:24:19 +01:00
ipfs-boards/webapp/pages/postpage.jsx

40 lines
1.4 KiB
React
Raw Normal View History

var React = require('react')
2015-11-23 16:07:04 +01:00
var Link = require('react-router').Link
var UserID = require('userID.jsx')
var GetIPFS = require('getipfs.jsx')
var Post = require('post.jsx')
module.exports = function (boardsAPI) {
return React.createClass({
getInitialState: function () {
2015-12-17 22:19:21 +01:00
return { }
},
componentDidMount: function () {
2015-11-23 13:00:49 +01:00
boardsAPI.use(boards => {
2015-12-18 22:22:26 +01:00
this.setState({ api: boards })
})
},
getContext: function () {
if (this.props.params.userid) {
if (this.props.params.boardname) {
2015-12-18 22:22:26 +01:00
return <div>Posted by <UserID id={this.props.params.userid} api={this.state.api} /> in <Link to={'@' + this.props.params.userid + '/' + this.props.params.boardname}>#{this.props.params.boardname}</Link></div>
} else {
2015-12-18 22:22:26 +01:00
return <div>Posted by <UserID id={this.props.params.userid} api={this.state.api} /></div>
}
2015-11-23 16:07:04 +01:00
} else return <div><h6 className="light">You are viewing a single post</h6></div>
},
render: function () {
if (this.state.api) {
2015-11-23 16:07:04 +01:00
return <div className="post-page">
<div className="text-center">
{this.getContext()}
</div>
2015-12-21 16:12:19 +01:00
<Post hash={this.props.params.posthash} board={this.props.params.boardname} api={this.state.api} adminID={this.props.params.userid} />
2015-11-23 16:07:04 +01:00
</div>
} else {
return <GetIPFS api={this.state.boards} />
}
}
})
}