0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-15 10:32:45 +00:00

Merge branch 'createBasePages' of https://github.com/G-Ambatte/homebrewery into createBasePages

# Conflicts:
#	client/homebrew/pages/userPage/userPage.jsx
This commit is contained in:
G.Ambatte
2021-12-31 13:11:50 +13:00

View File

@@ -3,16 +3,7 @@ const createClass = require('create-react-class');
const _ = require('lodash'); const _ = require('lodash');
const cx = require('classnames'); const cx = require('classnames');
const moment = require('moment'); const ListPage = require('../basePages/listPage/listPage.jsx');
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
const Account = require('../../navbar/account.navitem.jsx');
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
const BrewItem = require('./brewItem/brewItem.jsx');
const ReportIssue = require('../../navbar/issue.navitem.jsx');
// const brew = { // const brew = {
// title : 'SUPER Long title woah now', // title : 'SUPER Long title woah now',
@@ -145,12 +136,7 @@ const UserPage = createClass({
}, },
getSortedBrews : function(){ getSortedBrews : function(){
const testString = _.deburr(this.state.filterString).toLowerCase(); return _.groupBy(this.props.brews, (brew)=>{
const brewCollection = this.state.filterString ? _.filter(this.props.brews, (brew)=>{
return (_.deburr(brew.title).toLowerCase().includes(testString)) ||
(_.deburr(brew.description).toLowerCase().includes(testString));
}) : this.props.brews;
return _.groupBy(brewCollection, (brew)=>{
return (brew.published ? 'published' : 'private'); return (brew.published ? 'published' : 'private');
}); });
}, },
@@ -158,33 +144,24 @@ const UserPage = createClass({
render : function(){ render : function(){
const brews = this.getSortedBrews(); const brews = this.getSortedBrews();
return <div className='userPage sitePage'> const brewCollections = [
<link href='/themes/5ePhbLegacy.style.css' rel='stylesheet'/> {
<Navbar> title : `${this.getUsernameWithS()} published brews`,
<Nav.section> class : 'published',
<NewBrew /> brews : brews.published
<ReportIssue /> }
<RecentNavItem /> ];
<Account /> if(this.props.username == global.account?.username){
</Nav.section> brewCollections.push(
</Navbar> {
title : `${this.getUsernameWithS()} unpublished brews`,
class : 'unpublished',
brews : brews.private
}
);
}
<div className='content V3'> return <ListPage brewCollection={brewCollections} ></ListPage>;
<div className='phb'>
{this.renderSortOptions()}
<div className='published'>
<h1>{this.getUsernameWithS()} published brews</h1>
{this.renderBrews(brews.published)}
</div>
{this.props.username == global.account?.username &&
<div className='unpublished'>
<h1>{this.getUsernameWithS()} unpublished brews</h1>
{this.renderBrews(brews.private)}
</div>
}
</div>
</div>
</div>;
} }
}); });