0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-09 13:42:38 +00:00

Move Nav items to UserPage

This commit is contained in:
G.Ambatte
2022-02-05 17:01:52 +13:00
parent 660004e348
commit 0611db1bdf
2 changed files with 31 additions and 24 deletions

View File

@@ -4,16 +4,9 @@ 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 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 BrewItem = require('./brewItem/brewItem.jsx');
const ReportIssue = require('../../../navbar/issue.navitem.jsx');
const moment = require('moment');
// const brew = { // const brew = {
// title : 'SUPER Long title woah now', // title : 'SUPER Long title woah now',
@@ -32,7 +25,8 @@ const ListPage = createClass({
class : '', class : '',
brews : [] brews : []
} }
] ],
navItems : <></>
}; };
}, },
getInitialState : function() { getInitialState : function() {
@@ -146,16 +140,17 @@ const ListPage = createClass({
getSortedBrews : function(brewCollection){ getSortedBrews : function(brewCollection){
const testString = _.deburr(this.state.filterString).toLowerCase(); const testString = _.deburr(this.state.filterString).toLowerCase();
const brews = this.state.filterString ? _.filter(brewCollection.brews, (brew)=>{ console.log(testString);
const brews = testString ? _.filter(brewCollection.brews, (brew)=>{
return (_.deburr(brew.title).toLowerCase().includes(testString)) || return (_.deburr(brew.title).toLowerCase().includes(testString)) ||
(_.deburr(brew.description).toLowerCase().includes(testString)); (_.deburr(brew.description).toLowerCase().includes(testString));
}) : this.props.brewCollection.brews; }) : brewCollection.brews;
return _.groupBy(brews, (brew)=>{ console.log(brews);
return (brew.published ? 'published' : 'private'); return brews;
});
}, },
renderBrewCollection : function(brewCollection){ renderBrewCollection : function(brewCollection){
brewCollection.brews = this.getSortedBrews(brewCollection);
return _.map(brewCollection, (brewItem, idx)=>{ return _.map(brewCollection, (brewItem, idx)=>{
return <div key={idx} className={`brewCollection${brewItem?.class ? ` ${brewItem.class}` : ''}`}> return <div key={idx} className={`brewCollection${brewItem?.class ? ` ${brewItem.class}` : ''}`}>
<h1>{brewItem.title || 'No Title'}</h1> <h1>{brewItem.title || 'No Title'}</h1>
@@ -167,14 +162,7 @@ const ListPage = createClass({
render : function(){ render : function(){
return <div className='listPage sitePage'> return <div className='listPage sitePage'>
<link href='/themes/5ePhbLegacy.style.css' rel='stylesheet'/> <link href='/themes/5ePhbLegacy.style.css' rel='stylesheet'/>
<Navbar> {this.props.navItems}
<Nav.section>
<NewBrew />
<ReportIssue />
<RecentNavItem />
<Account />
</Nav.section>
</Navbar>
<div className='content V3'> <div className='content V3'>
<div className='phb'> <div className='phb'>

View File

@@ -5,6 +5,14 @@ const cx = require('classnames');
const ListPage = require('../basePages/listPage/listPage.jsx'); 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 ReportIssue = require('../../navbar/issue.navitem.jsx');
const UserPage = createClass({ const UserPage = createClass({
displayName : 'UserPage', displayName : 'UserPage',
getDefaultProps : function() { getDefaultProps : function() {
@@ -42,8 +50,19 @@ const UserPage = createClass({
}; };
}, },
navItems : function() {
return <Navbar>
<Nav.section>
<NewBrew />
<ReportIssue />
<RecentNavItem />
<Account />
</Nav.section>
</Navbar>;
},
render : function(){ render : function(){
return <ListPage brewCollection={this.state.brewCollection} ></ListPage>; return <ListPage brewCollection={this.state.brewCollection} navItems={this.navItems()}></ListPage>;
} }
}); });