2015-11-14 01:34:03 +01:00
|
|
|
var React = require('react')
|
|
|
|
var ReactDOM = require('react-dom')
|
2015-11-14 12:06:37 +01:00
|
|
|
var ipfs = require('ipfs-api')('localhost',5001)
|
|
|
|
var BoardsAPI = require('../lib/boards-api.js')
|
|
|
|
|
|
|
|
var boards = new BoardsAPI(ipfs)
|
|
|
|
|
|
|
|
var Container = React.createClass({
|
|
|
|
render: function(){
|
|
|
|
return ( <div className="container app">{this.props.children}</div> )
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var App = React.createClass({
|
|
|
|
render: function(){
|
|
|
|
return ( <div><Navbar /><Container>{this.props.children}</Container></div> )
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var Homepage = React.createClass({
|
|
|
|
render: function(){
|
|
|
|
return (
|
|
|
|
<h3>Hello</h3>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var Navbar = React.createClass({
|
|
|
|
render: function(){
|
|
|
|
return (
|
|
|
|
<div className="navbar">
|
|
|
|
<div className="container">
|
|
|
|
<h4>Boards</h4>
|
|
|
|
</div>
|
|
|
|
</div>)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var Profile = React.createClass({
|
|
|
|
getInitialState: function(){
|
|
|
|
return { name: '...' }
|
|
|
|
},
|
|
|
|
componentDidMount: function(){
|
|
|
|
boards.getProfile(this.props.id, (err,res) => {
|
|
|
|
if(err){
|
|
|
|
console.log(err)
|
2015-11-14 12:14:00 +01:00
|
|
|
this.setState({
|
|
|
|
name: '?',
|
|
|
|
error: 'Invalid profile'
|
|
|
|
})
|
2015-11-14 12:06:37 +01:00
|
|
|
} else {
|
|
|
|
console.log(res)
|
|
|
|
this.setState({ name: res.name })
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
render: function(){
|
|
|
|
return (<div className="profile">
|
|
|
|
<h1>{this.state.name}</h1>
|
2015-11-14 12:14:00 +01:00
|
|
|
<p>{this.state.error}</p>
|
2015-11-14 12:06:37 +01:00
|
|
|
<h5 className="light">@{this.props.id}</h5>
|
|
|
|
</div>)
|
|
|
|
}
|
|
|
|
})
|
2015-11-14 01:34:03 +01:00
|
|
|
|
|
|
|
ReactDOM.render(
|
2015-11-14 12:06:37 +01:00
|
|
|
<App><Profile id="QmXnfA41SXMX3tqFD4kjED7ehyvgTsuAho86TkEoTbZdpw"/></App>, document.getElementById('root')
|
2015-11-14 10:46:42 +01:00
|
|
|
)
|