mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-29 13:22:40 +00:00
74 lines
1.6 KiB
JavaScript
74 lines
1.6 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 RecentNavItem = require('../../navbar/recent.navitem.jsx');
|
|
const Account = require('../../navbar/account.navitem.jsx');
|
|
const BrewItem = require('./brewItem/brewItem.jsx');
|
|
|
|
const brew = {
|
|
title : 'SUPER Long title woah now',
|
|
authors : []
|
|
}
|
|
|
|
const BREWS = _.times(25, ()=>{ return brew});
|
|
|
|
|
|
const UserPage = React.createClass({
|
|
getDefaultProps: function() {
|
|
return {
|
|
username : '',
|
|
brews : []
|
|
};
|
|
},
|
|
|
|
renderBrews : function(brews){
|
|
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>
|
|
|
|
return _.map(brews, (brew, idx) => {
|
|
return <BrewItem brew={brew} key={idx}/>
|
|
});
|
|
},
|
|
|
|
getSortedBrews : function(){
|
|
return _.groupBy(this.props.brews, (brew)=>{
|
|
return (brew.published ? 'published' : 'private')
|
|
});
|
|
},
|
|
|
|
renderPrivateBrews : function(privateBrews){
|
|
if(!privateBrews || !privateBrews.length) return;
|
|
|
|
return [
|
|
<h1>{this.props.username}'s unpublished brews</h1>,
|
|
this.renderBrews(privateBrews)
|
|
];
|
|
},
|
|
|
|
render : function(){
|
|
const brews = this.getSortedBrews();
|
|
|
|
return <div className='userPage page'>
|
|
<Navbar>
|
|
<Nav.section>
|
|
<RecentNavItem.both />
|
|
<Account />
|
|
</Nav.section>
|
|
</Navbar>
|
|
|
|
<div className='content'>
|
|
<div className='phb'>
|
|
<h1>{this.props.username}'s brews</h1>
|
|
{this.renderBrews(brews.published)}
|
|
{this.renderPrivateBrews(brews.private)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
});
|
|
|
|
module.exports = UserPage;
|