diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 19a09c3fe..b60a318be 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -55,6 +55,7 @@ const EditPage = createClass({ isSaving : false, isPending : false, alertTrashedGoogleBrew : this.props.brew.trashed, + alertLoginToTransfer : false, saveGoogle : this.props.brew.googleId ? true : false, confirmGoogleTransfer : false, errors : null, @@ -140,15 +141,25 @@ const EditPage = createClass({ }, handleGoogleClick : function(){ + console.log('handlegoogleclick'); + if(!global.account?.googleId) { + this.setState({ + alertLoginToTransfer : true + }); + return; + } this.setState((prevState)=>({ confirmGoogleTransfer : !prevState.confirmGoogleTransfer })); this.clearErrors(); }, - closeAlerts : function(){ + closeAlerts : function(event){ + event.stopPropagation(); //Only handle click once so alert doesn't reopen this.setState({ - alertTrashedGoogleBrew : false + alertTrashedGoogleBrew : false, + alertLoginToTransfer : false, + confirmGoogleTransfer : false }); }, @@ -187,7 +198,7 @@ const EditPage = createClass({ .catch((err)=>{ console.log(err.status === 401 ? 'Not signed in!' - : 'Error Saving to Google!'); + : 'Error Transferring to Google!'); this.setState({ errors: err, saveGoogle: false }); }); @@ -210,7 +221,7 @@ const EditPage = createClass({ console.log(err.status === 401 ? 'Not signed in!' : 'Error Saving to Google!'); - this.setState({ errors: err, saveGoogle: false }); + this.setState({ errors: err }); return; }); @@ -260,39 +271,44 @@ const EditPage = createClass({ }, renderGoogleDriveIcon : function(){ - if(this.state.saveGoogle) { - return - googleDriveActive + return + {this.state.saveGoogle + ? googleDriveActive + : googleDriveInactive + } - {this.state.confirmGoogleTransfer && -
- Would you like to transfer this brew from your Google Drive storage back to the Homebrewery?
-
- Yes -
-
- No -
+ {this.state.confirmGoogleTransfer && +
+ { this.state.saveGoogle + ? `Would you like to transfer this brew from your Google Drive storage back to the Homebrewery?` + : `Would you like to transfer this brew from the Homebrewery to your personal Google Drive storage?` + } +
+
+ Yes
- } - ; - } else { - return - googleDriveInactive +
+ No +
+
+ } - {this.state.confirmGoogleTransfer && -
- Would you like to transfer this brew from the Homebrewery to your personal Google Drive storage?
-
- Yes -
-
- No + {this.state.alertLoginToTransfer && +
+ You must be signed in to a Google account to transfer + between the homebrewery and Google Drive! + +
+ Sign In
+
+
+ Not Now
- } - ; - } +
+ } + ; }, renderSaveButton : function(){ @@ -311,7 +327,7 @@ const EditPage = createClass({ to save this to
Google Drive!
-