mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 18:52:38 +00:00
Add createdTime to G-Drive fields to retrieve
Add Moment to UserPage sorting
This commit is contained in:
@@ -4,6 +4,8 @@ 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 Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ const UserPage = createClass({
|
|||||||
renderBrews : function(brews){
|
renderBrews : function(brews){
|
||||||
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
||||||
|
|
||||||
const sortedBrews = this.sortBrews(brews);
|
const sortedBrews = this.sortBrews(brews, this.state.sortType);
|
||||||
|
|
||||||
return _.map(sortedBrews, (brew, idx)=>{
|
return _.map(sortedBrews, (brew, idx)=>{
|
||||||
return <BrewItem brew={brew} key={idx}/>;
|
return <BrewItem brew={brew} key={idx}/>;
|
||||||
@@ -50,13 +52,12 @@ const UserPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
sortBrewOrder : function(brew){
|
sortBrewOrder : function(brew){
|
||||||
if(!brew.title){brew.title = 'No Title';};
|
|
||||||
const mapping = {
|
const mapping = {
|
||||||
'alpha' : _.deburr(brew.title.toLowerCase()),
|
'alpha' : _.deburr(brew.title.toLowerCase()),
|
||||||
'created' : brew.createdAt,
|
'created' : moment(brew.createdAt).format(),
|
||||||
'updated' : brew.updatedAt,
|
'updated' : moment(brew.updatedAt).format(),
|
||||||
'views' : brew.views,
|
'views' : brew.views,
|
||||||
'latest' : brew.lastViewed
|
'latest' : moment(brew.lastViewed).format()
|
||||||
};
|
};
|
||||||
return mapping[this.state.sortType];
|
return mapping[this.state.sortType];
|
||||||
},
|
},
|
||||||
@@ -141,11 +142,11 @@ const UserPage = createClass({
|
|||||||
<div className='content V3'>
|
<div className='content V3'>
|
||||||
<div className='phb'>
|
<div className='phb'>
|
||||||
{this.renderSortOptions()}
|
{this.renderSortOptions()}
|
||||||
<div>
|
<div className='published'>
|
||||||
<h1>{this.getUsernameWithS()} brews</h1>
|
<h1>{this.getUsernameWithS()} brews</h1>
|
||||||
{this.renderBrews(brews.published)}
|
{this.renderBrews(brews.published)}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className='unpublished'>
|
||||||
<h1>{this.getUsernameWithS()} unpublished brews</h1>
|
<h1>{this.getUsernameWithS()} unpublished brews</h1>
|
||||||
{this.renderBrews(brews.private)}
|
{this.renderBrews(brews.private)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ GoogleActions = {
|
|||||||
|
|
||||||
const obj = await drive.files.list({
|
const obj = await drive.files.list({
|
||||||
pageSize : 100,
|
pageSize : 100,
|
||||||
fields : 'nextPageToken, files(id, name, description, modifiedTime, properties)',
|
fields : 'nextPageToken, files(id, name, description, createdTime, modifiedTime, properties)',
|
||||||
q : 'mimeType != \'application/vnd.google-apps.folder\' and trashed = false'
|
q : 'mimeType != \'application/vnd.google-apps.folder\' and trashed = false'
|
||||||
})
|
})
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user