0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-19 16:22:41 +00:00

Initial Commit. All seems to be working...?

EditPage.jsx and GoogleActions.js need to be cleaned up and shortened...
This commit is contained in:
Trevor Buckner
2020-10-05 23:33:15 -04:00
parent 2065ff80ff
commit 35e1ce0df2
19 changed files with 1148 additions and 108 deletions

View File

@@ -24,6 +24,7 @@ const NewPage = createClass({
getInitialState : function() {
return {
metadata : {
gDrive : false,
title : '',
description : '',
tags : '',
@@ -32,11 +33,13 @@ const NewPage = createClass({
systems : []
},
text : '',
isSaving : false,
errors : []
text : '',
isSaving : false,
saveGoogle : (global.account.googleId ? true : false),
errors : []
};
},
componentDidMount : function() {
const storage = localStorage.getItem(KEY);
if(storage){
@@ -80,12 +83,30 @@ const NewPage = createClass({
localStorage.setItem(KEY, text);
},
save : function(){
save : async function(){
this.setState({
isSaving : true
});
request.post('/api')
console.log('saving new brew');
if(this.state.saveGoogle) {
const res = await request
.post('/api/newGoogle/')
.send(_.merge({}, this.state.metadata, { text: this.state.text }))
.catch((err)=>{
console.log(err.status === 401
? 'Not signed in!'
: 'Error Creating New Google Brew!');
this.setState({ isSaving: false });
return;
});
const brew = res.body;
localStorage.removeItem(KEY);
window.location = `/edit/${brew.googleId}${brew.editId}`;
} else {
request.post('/api')
.send(_.merge({}, this.state.metadata, {
text : this.state.text
}))
@@ -101,6 +122,8 @@ const NewPage = createClass({
localStorage.removeItem(KEY);
window.location = `/edit/${brew.editId}`;
});
}
},
renderSaveButton : function(){