mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-11 11:12:44 +00:00
Remove test UI page, add initial Account page
This commit is contained in:
@@ -11,6 +11,7 @@ const SharePage = require('./pages/sharePage/sharePage.jsx');
|
|||||||
const NewPage = require('./pages/newPage/newPage.jsx');
|
const NewPage = require('./pages/newPage/newPage.jsx');
|
||||||
//const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
//const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
||||||
const PrintPage = require('./pages/printPage/printPage.jsx');
|
const PrintPage = require('./pages/printPage/printPage.jsx');
|
||||||
|
const AccountPage = require('./pages/accountPage/accountPage.jsx');
|
||||||
const UIPage = require('./pages/basePages/uiPage/uiPage.jsx');
|
const UIPage = require('./pages/basePages/uiPage/uiPage.jsx');
|
||||||
|
|
||||||
const Homebrew = createClass({
|
const Homebrew = createClass({
|
||||||
@@ -57,8 +58,8 @@ const Homebrew = createClass({
|
|||||||
<Route path='/print' exact component={(routeProps)=><PrintPage query={queryString.parse(routeProps.location.search)} />}/>
|
<Route path='/print' exact component={(routeProps)=><PrintPage query={queryString.parse(routeProps.location.search)} />}/>
|
||||||
<Route path='/changelog' exact component={()=><SharePage brew={this.props.brew} />}/>
|
<Route path='/changelog' exact component={()=><SharePage brew={this.props.brew} />}/>
|
||||||
<Route path='/faq' exact component={()=><SharePage brew={this.props.brew} />}/>
|
<Route path='/faq' exact component={()=><SharePage brew={this.props.brew} />}/>
|
||||||
<Route path='/ui' exact component={()=><UIPage brew={this.props.brew} uiItems={this.props.uiItems} />}/>
|
|
||||||
<Route path='/v3_preview' exact component={()=><HomePage brew={this.props.brew} />}/>
|
<Route path='/v3_preview' exact component={()=><HomePage brew={this.props.brew} />}/>
|
||||||
|
<Route path='/ui/account' exact component={()=><AccountPage brew={this.props.brew} uiItems={this.props.brew.uiItems} />}/>
|
||||||
<Route path='/' component={()=><HomePage brew={this.props.brew} />}/>
|
<Route path='/' component={()=><HomePage brew={this.props.brew} />}/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
56
client/homebrew/pages/accountPage/accountPage.jsx
Normal file
56
client/homebrew/pages/accountPage/accountPage.jsx
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
const React = require('react');
|
||||||
|
const createClass = require('create-react-class');
|
||||||
|
const _ = require('lodash');
|
||||||
|
const cx = require('classnames');
|
||||||
|
|
||||||
|
const UIPage = require('../basePages/uiPage/uiPage.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 HelpNavItem = require('../../navbar/help.navitem.jsx');
|
||||||
|
|
||||||
|
const AccountPage = createClass({
|
||||||
|
displayName : 'AccountPage',
|
||||||
|
getDefaultProps : function() {
|
||||||
|
return {
|
||||||
|
brew : {},
|
||||||
|
uiItems : []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getInitialState : function() {
|
||||||
|
return {
|
||||||
|
uiItems : this.props.uiItems
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
navItems : function() {
|
||||||
|
return <Navbar>
|
||||||
|
<Nav.section>
|
||||||
|
<NewBrew />
|
||||||
|
<HelpNavItem />
|
||||||
|
<RecentNavItem />
|
||||||
|
<Account />
|
||||||
|
</Nav.section>
|
||||||
|
</Navbar>;
|
||||||
|
},
|
||||||
|
|
||||||
|
uiItems : function() {
|
||||||
|
const result = <>
|
||||||
|
<h1>Account Information</h1>
|
||||||
|
<p><strong>Username: </strong> {this.props.uiItems.username}</p>
|
||||||
|
<p><strong>Issued: </strong> {this.props.uiItems.issued}</p>
|
||||||
|
</>;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
render : function(){
|
||||||
|
return <UIPage brew={this.props.brew} uiItems={this.uiItems()} ></UIPage>;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = AccountPage;
|
||||||
@@ -272,11 +272,42 @@ app.get('/print/:id', asyncHandler(async (req, res, next)=>{
|
|||||||
return next();
|
return next();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//UI Page
|
//Account Page
|
||||||
app.get('/ui', asyncHandler(async (req, res, next)=>{
|
app.get('/ui/account', asyncHandler(async (req, res, next)=>{
|
||||||
const brew = {
|
const brew = {};
|
||||||
title : 'UI PAGE'
|
brew.title = 'ACCOUNT';
|
||||||
};
|
|
||||||
|
let auth;
|
||||||
|
let files;
|
||||||
|
if(req.account) {
|
||||||
|
if(req.account.googleId) {
|
||||||
|
try {
|
||||||
|
auth = await GoogleActions.authCheck(req.account, res);
|
||||||
|
} catch (e) {
|
||||||
|
auth = undefined;
|
||||||
|
console.log('Google auth check failed!');
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
if(auth.credentials.access_token) {
|
||||||
|
try {
|
||||||
|
files = await GoogleActions.listGoogleBrews(auth);
|
||||||
|
} catch (e) {
|
||||||
|
files = undefined;
|
||||||
|
console.log('List Google files failed!');
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
brew.uiItems = {
|
||||||
|
username : req.account.username,
|
||||||
|
issued : req.account.issued,
|
||||||
|
googleId : Boolean(req.account.googleId),
|
||||||
|
authCheck : Boolean(req.account.googleId && auth.credentials.access_token),
|
||||||
|
fileCount : files?.length
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
req.brew = brew;
|
req.brew = brew;
|
||||||
return next();
|
return next();
|
||||||
}));
|
}));
|
||||||
@@ -298,6 +329,7 @@ if(isLocalEnvironment){
|
|||||||
|
|
||||||
//Render the page
|
//Render the page
|
||||||
const templateFn = require('./../client/template.js');
|
const templateFn = require('./../client/template.js');
|
||||||
|
|
||||||
app.use((req, res)=>{
|
app.use((req, res)=>{
|
||||||
// Create configuration object
|
// Create configuration object
|
||||||
const configuration = {
|
const configuration = {
|
||||||
|
|||||||
Reference in New Issue
Block a user