mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-19 09:28:30 +00:00
Merge pull request #5195 from naturalcrit/cleanup-Listpage
Cleanup listpage `renderBrewCollection()`
This commit is contained in:
@@ -202,9 +202,9 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
const filterTextTest = brewStrings.includes(testString);
|
const filterTextTest = brewStrings.includes(testString);
|
||||||
|
|
||||||
// Filter by user selected tags
|
// Filter by user selected tags
|
||||||
const filterTagTest = filterTags.every((tag)=>{
|
const filterTagTest = filterTags.every((tag)=>
|
||||||
Array.isArray(brew.tags) && //TODO: brew.tags should be converted to array at load so we don't have to catch it here
|
Array.isArray(brew.tags) && //TODO: brew.tags should be converted to array at load so we don't have to catch it here
|
||||||
brew.tags.some((brewTag)=>brewTag.toLowerCase() == tag.toLowerCase())}
|
brew.tags.some((brewTag)=>brewTag.toLowerCase() == tag.toLowerCase())
|
||||||
);
|
);
|
||||||
|
|
||||||
return filterTextTest && filterTagTest;
|
return filterTextTest && filterTagTest;
|
||||||
@@ -233,28 +233,21 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderBrewCollection = (brewCollection)=>{
|
const renderBrewCollection = ()=>{
|
||||||
if(brewCollection.length === 0)
|
if(sortedBrewCollection.length === 0)
|
||||||
return (
|
return <h1>No Brews</h1>;
|
||||||
<div className='brewCollection'>
|
|
||||||
<h1>No Brews</h1>
|
return _.map(sortedBrewCollection, (brewGroup, idx)=>{
|
||||||
</div>
|
|
||||||
);
|
|
||||||
return _.map(brewCollection, (brewGroup, idx)=>{
|
|
||||||
const sortedBrewGroup = sortedBrewCollection[idx];
|
|
||||||
const visible = groupVisibility[brewGroup.class];
|
const visible = groupVisibility[brewGroup.class];
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
<h1
|
<h1
|
||||||
className={visible ? 'active' : 'inactive'}
|
className={visible ? 'active' : 'inactive'}
|
||||||
onClick={()=>{
|
onClick={()=>toggleBrewCollectionState(brewGroup.class)}>
|
||||||
toggleBrewCollectionState(brewGroup.class);
|
|
||||||
}}>
|
|
||||||
{brewGroup.title || 'No Title'}
|
{brewGroup.title || 'No Title'}
|
||||||
</h1>
|
</h1>
|
||||||
<div key={idx} className={`brewGroup ${brewGroup.class ?? ''} ${layoutMode}`}>
|
<div key={idx} className={`brewGroup ${brewGroup.class ?? ''} ${layoutMode}`}>
|
||||||
|
{visible ? renderBrews(brewGroup.brews) : <></>}
|
||||||
{visible ? renderBrews(sortedBrewGroup.brews) : <></>}
|
|
||||||
</div>
|
</div>
|
||||||
</>);
|
</>);
|
||||||
});
|
});
|
||||||
@@ -318,7 +311,6 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
{renderTagsOptions()}
|
{renderTagsOptions()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -328,7 +320,7 @@ const ListPage = ({ brewCollection = [{ title: '', class: '', brews: [] }], navI
|
|||||||
{renderNav()}
|
{renderNav()}
|
||||||
|
|
||||||
<div className={`content V3 ${`${themeMode}Mode`}`}>
|
<div className={`content V3 ${`${themeMode}Mode`}`}>
|
||||||
<div className='brewCollection'>{renderBrewCollection(brewCollection)}</div>
|
<div className='brewCollection'>{renderBrewCollection()}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user