diff --git a/client/homebrew/pages/userPage/userPage.jsx b/client/homebrew/pages/userPage/userPage.jsx
index 9fcddd497..c3ac93e43 100644
--- a/client/homebrew/pages/userPage/userPage.jsx
+++ b/client/homebrew/pages/userPage/userPage.jsx
@@ -5,14 +5,6 @@ const cx = require('classnames');
const ListPage = require('../basePages/listPage/listPage.jsx');
-// const brew = {
-// title : 'SUPER Long title woah now',
-// authors : []
-// };
-
-//const BREWS = _.times(25, ()=>{ return brew;});
-
-
const UserPage = createClass({
displayName : 'UserPage',
getDefaultProps : function() {
@@ -22,146 +14,36 @@ const UserPage = createClass({
};
},
getInitialState : function() {
- return {
- sortType : 'alpha',
- sortDir : 'asc',
- filterString : ''
- };
- },
- getUsernameWithS : function() {
- if(this.props.username.endsWith('s'))
- return `${this.props.username}'`;
- return `${this.props.username}'s`;
- },
+ const usernameWithS = this.props.username + (this.props.username.endsWith('s') ? `'` : `'s`);
- renderBrews : function(brews){
- if(!brews || !brews.length) return
No Brews.
;
-
- const sortedBrews = this.sortBrews(brews);
-
- return _.map(sortedBrews, (brew, idx)=>{
- return ;
- });
- },
-
- sortBrewOrder : function(brew){
- if(!brew.title){brew.title = 'No Title';}
- const mapping = {
- 'alpha' : _.deburr(brew.title.toLowerCase()),
- 'created' : moment(brew.createdAt).format(),
- 'updated' : moment(brew.updatedAt).format(),
- 'views' : brew.views,
- 'latest' : moment(brew.lastViewed).format()
- };
- return mapping[this.state.sortType];
- },
-
- sortBrews : function(brews){
- return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir);
- },
-
- handleSortOptionChange : function(event){
- this.setState({
- sortType : event.target.value
- });
- },
-
- handleSortDirChange : function(event){
- this.setState({
- sortDir : `${(this.state.sortDir == 'asc' ? 'desc' : 'asc')}`
- });
- },
-
- renderSortOption : function(sortTitle, sortValue){
- return
-
- | ;
- },
-
- handleFilterTextChange : function(e){
- this.setState({
- filterString : e.target.value
- });
- return;
- },
-
- renderFilterOption : function(){
- return
-
- | ;
- },
-
- renderSortOptions : function(){
- return
-
-
-
-
- Sort by :
- |
- {this.renderSortOption('Title', 'alpha')}
- {this.renderSortOption('Created Date', 'created')}
- {this.renderSortOption('Updated Date', 'updated')}
- {this.renderSortOption('Views', 'views')}
- {/* {this.renderSortOption('Latest', 'latest')} */}
-
- Direction :
- |
-
-
- |
- {this.renderFilterOption()}
-
-
-
-
;
- },
-
- getSortedBrews : function(){
- return _.groupBy(this.props.brews, (brew)=>{
+ const brews = _.groupBy(this.props.brews, (brew)=>{
return (brew.published ? 'published' : 'private');
});
- },
- render : function(){
- const brews = this.getSortedBrews();
-
- const brewCollections = [
+ const brewCollection = [
{
- title : `${this.getUsernameWithS()} published brews`,
+ title : `${usernameWithS} published brews`,
class : 'published',
brews : brews.published
}
];
if(this.props.username == global.account?.username){
- brewCollections.push(
+ brewCollection.push(
{
- title : `${this.getUsernameWithS()} unpublished brews`,
+ title : `${usernameWithS} unpublished brews`,
class : 'unpublished',
brews : brews.private
}
);
}
- return ;
+ return {
+ brewCollection : brewCollection
+ };
+ },
+
+ render : function(){
+ return ;
}
});