mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 12:42:41 +00:00
Merge pull request #1327 from naturalcrit/FixAccidentalGoogleToHBTransfers
Fix accidental google to hb transfers
This commit is contained in:
@@ -55,6 +55,7 @@ const EditPage = createClass({
|
|||||||
isSaving : false,
|
isSaving : false,
|
||||||
isPending : false,
|
isPending : false,
|
||||||
alertTrashedGoogleBrew : this.props.brew.trashed,
|
alertTrashedGoogleBrew : this.props.brew.trashed,
|
||||||
|
alertLoginToTransfer : false,
|
||||||
saveGoogle : this.props.brew.googleId ? true : false,
|
saveGoogle : this.props.brew.googleId ? true : false,
|
||||||
confirmGoogleTransfer : false,
|
confirmGoogleTransfer : false,
|
||||||
errors : null,
|
errors : null,
|
||||||
@@ -140,15 +141,25 @@ const EditPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleGoogleClick : function(){
|
handleGoogleClick : function(){
|
||||||
|
console.log('handlegoogleclick');
|
||||||
|
if(!global.account?.googleId) {
|
||||||
|
this.setState({
|
||||||
|
alertLoginToTransfer : true
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
confirmGoogleTransfer : !prevState.confirmGoogleTransfer
|
confirmGoogleTransfer : !prevState.confirmGoogleTransfer
|
||||||
}));
|
}));
|
||||||
this.clearErrors();
|
this.clearErrors();
|
||||||
},
|
},
|
||||||
|
|
||||||
closeAlerts : function(){
|
closeAlerts : function(event){
|
||||||
|
event.stopPropagation(); //Only handle click once so alert doesn't reopen
|
||||||
this.setState({
|
this.setState({
|
||||||
alertTrashedGoogleBrew : false
|
alertTrashedGoogleBrew : false,
|
||||||
|
alertLoginToTransfer : false,
|
||||||
|
confirmGoogleTransfer : false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -187,7 +198,7 @@ const EditPage = createClass({
|
|||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err.status === 401
|
console.log(err.status === 401
|
||||||
? 'Not signed in!'
|
? 'Not signed in!'
|
||||||
: 'Error Saving to Google!');
|
: 'Error Transferring to Google!');
|
||||||
this.setState({ errors: err, saveGoogle: false });
|
this.setState({ errors: err, saveGoogle: false });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -210,7 +221,7 @@ const EditPage = createClass({
|
|||||||
console.log(err.status === 401
|
console.log(err.status === 401
|
||||||
? 'Not signed in!'
|
? 'Not signed in!'
|
||||||
: 'Error Saving to Google!');
|
: 'Error Saving to Google!');
|
||||||
this.setState({ errors: err, saveGoogle: false });
|
this.setState({ errors: err });
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -260,39 +271,44 @@ const EditPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderGoogleDriveIcon : function(){
|
renderGoogleDriveIcon : function(){
|
||||||
if(this.state.saveGoogle) {
|
return <Nav.item className='googleDriveStorage' onClick={this.handleGoogleClick}>
|
||||||
return <Nav.item className='googleDriveStorage' onClick={this.handleGoogleClick}>
|
{this.state.saveGoogle
|
||||||
<img src={googleDriveActive} alt='googleDriveActive' />
|
? <img src={googleDriveActive} alt='googleDriveActive'/>
|
||||||
|
: <img src={googleDriveInactive} alt='googleDriveInactive'/>
|
||||||
|
}
|
||||||
|
|
||||||
{this.state.confirmGoogleTransfer &&
|
{this.state.confirmGoogleTransfer &&
|
||||||
<div className='errorContainer'>
|
<div className='errorContainer' onClick={this.closeAlerts}>
|
||||||
Would you like to transfer this brew from your Google Drive storage back to the Homebrewery?<br />
|
{ this.state.saveGoogle
|
||||||
<div className='confirm' onClick={this.toggleGoogleStorage}>
|
? `Would you like to transfer this brew from your Google Drive storage back to the Homebrewery?`
|
||||||
Yes
|
: `Would you like to transfer this brew from the Homebrewery to your personal Google Drive storage?`
|
||||||
</div>
|
}
|
||||||
<div className='deny'>
|
<br />
|
||||||
No
|
<div className='confirm' onClick={this.toggleGoogleStorage}>
|
||||||
</div>
|
Yes
|
||||||
</div>
|
</div>
|
||||||
}
|
<div className='deny'>
|
||||||
</Nav.item>;
|
No
|
||||||
} else {
|
</div>
|
||||||
return <Nav.item className='googleDriveStorage' onClick={this.handleGoogleClick}>
|
</div>
|
||||||
<img src={googleDriveInactive} alt='googleDriveInactive' />
|
}
|
||||||
|
|
||||||
{this.state.confirmGoogleTransfer &&
|
{this.state.alertLoginToTransfer &&
|
||||||
<div className='errorContainer'>
|
<div className='errorContainer' onClick={this.closeAlerts}>
|
||||||
Would you like to transfer this brew from the Homebrewery to your personal Google Drive storage?<br />
|
You must be signed in to a Google account to transfer
|
||||||
<div className='confirm' onClick={this.toggleGoogleStorage}>
|
between the homebrewery and Google Drive!
|
||||||
Yes
|
<a target='_blank' rel='noopener noreferrer'
|
||||||
</div>
|
href={`http://naturalcrit.com/login?redirect=${this.state.url}`}>
|
||||||
<div className='deny'>
|
<div className='confirm'>
|
||||||
No
|
Sign In
|
||||||
</div>
|
</div>
|
||||||
|
</a>
|
||||||
|
<div className='deny'>
|
||||||
|
Not Now
|
||||||
</div>
|
</div>
|
||||||
}
|
</div>
|
||||||
</Nav.item>;
|
}
|
||||||
}
|
</Nav.item>;
|
||||||
},
|
},
|
||||||
|
|
||||||
renderSaveButton : function(){
|
renderSaveButton : function(){
|
||||||
@@ -311,7 +327,7 @@ const EditPage = createClass({
|
|||||||
to save this to<br />Google Drive!<br />
|
to save this to<br />Google Drive!<br />
|
||||||
<a target='_blank' rel='noopener noreferrer'
|
<a target='_blank' rel='noopener noreferrer'
|
||||||
href={`http://naturalcrit.com/login?redirect=${this.state.url}`}>
|
href={`http://naturalcrit.com/login?redirect=${this.state.url}`}>
|
||||||
<div className='confirm' onClick={this.toggleGoogleStorage}>
|
<div className='confirm'>
|
||||||
Sign In
|
Sign In
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user