0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-05 18:52:38 +00:00
Files
homebrewery/client/homebrew/pages/userPage/userPage.jsx
2016-11-24 23:35:10 -05:00

52 lines
1.1 KiB
JavaScript

const React = require('react');
const _ = require('lodash');
const cx = require('classnames');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const BrewItem = require('./brewItem/brewItem.jsx');
const UserPage = React.createClass({
getDefaultProps: function() {
return {
username : '',
brews : []
};
},
renderBrews : function(brews){
return _.map(brews, (brew, idx) => {
return <BrewItem brew={brew} key={idx}/>
});
},
getSortedBrews : function(){
return _.groupBy(this.props.brews, (brew)=>{
return (brew.published ? 'published' : 'private')
});
},
render : function(){
const brews = this.getSortedBrews();
return <div className='userPage page'>
<Navbar>
<Nav.section>
holla
</Nav.section>
</Navbar>
<div className='content'>
<div className='phb'>
<h1>{this.props.username}'s brews</h1>
{this.renderBrews(brews.published)}
{brews.private ? <h1>{this.props.username}'s unpublished brews</h1> : null}
{this.renderBrews(brews.private)}
</div>
</div>
</div>
}
});
module.exports = UserPage;