0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Filtering now functional on ListPage

This commit is contained in:
G.Ambatte
2022-02-05 17:14:41 +13:00
parent 0611db1bdf
commit 6299e87569

View File

@@ -138,14 +138,12 @@ const ListPage = createClass({
</div>;
},
getSortedBrews : function(brewCollection){
getSortedBrews : function(brews){
const testString = _.deburr(this.state.filterString).toLowerCase();
console.log(testString);
const brews = testString ? _.filter(brewCollection.brews, (brew)=>{
brews = testString ? _.filter(brews, (brew)=>{
return (_.deburr(brew.title).toLowerCase().includes(testString)) ||
(_.deburr(brew.description).toLowerCase().includes(testString));
}) : brewCollection.brews;
console.log(brews);
}) : brews;
return brews;
},
@@ -154,7 +152,7 @@ const ListPage = createClass({
return _.map(brewCollection, (brewItem, idx)=>{
return <div key={idx} className={`brewCollection${brewItem?.class ? ` ${brewItem.class}` : ''}`}>
<h1>{brewItem.title || 'No Title'}</h1>
{this.renderBrews(brewItem.brews)}
{this.renderBrews(this.getSortedBrews(brewItem.brews))}
</div>;
});
},