diff --git a/src/components/ErrorAlert/index.js b/src/components/ErrorAlert/index.js index 87d606aaf9ca9c134714ee9a572678b70c6c1883..e0fdbc007142f890664a43709d676c3de513b6c4 100644 --- a/src/components/ErrorAlert/index.js +++ b/src/components/ErrorAlert/index.js @@ -15,7 +15,7 @@ class ErrorAlert extends Component { if (error) { error.responseBody.then((res) => { - this.setState({ errMessage: res.data }); + this.setState({ errMessage: JSON.stringify(res.data) }); }); } } diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index c526b49ed449ce8cb03d9d46b026aa72be7bdee7..a5cf9a18a5b42290260d726cac308b4c75e718b2 100644 --- a/src/components/Utilities/index.js +++ b/src/components/Utilities/index.js @@ -210,6 +210,7 @@ class Utilities extends Component { accountId = null, billData = [], disaggregateData = [], + ) => { let accountProps = {}; const { accountsCounter } = this.state; @@ -219,7 +220,7 @@ class Utilities extends Component { account_id: accountId, billData, disaggregateData, - disabled: true, + accountCreated: true, }; } diff --git a/src/components/UtilityAccount/index.js b/src/components/UtilityAccount/index.js index e6e9bf6e7864c799949efb22bf790408f203e740..f1be0dbfff5a281f46e50aef53ae6afb7381bea1 100644 --- a/src/components/UtilityAccount/index.js +++ b/src/components/UtilityAccount/index.js @@ -19,7 +19,8 @@ class UtilityAccount extends Component { account_id: this.props.account_id, billData: this.props.billData, disaggregateData: this.props.disaggregateData, - disabled: this.props.disabled, + accountCreated: this.props.accountCreated, + disableButtons: false, convertingFile: false, displayBillData: false, displayDisaggregateData: false, @@ -154,7 +155,12 @@ class UtilityAccount extends Component { handleCreateAccount = (event) => { event.preventDefault(); - this.setState({ disabled: true }); + this.setState({ + accountCreated: true, + // Disable all of the buttons until the create account returns succesfully + // The buttons will be reenabled when the component is recreated by the parent + disableButtons: true, + }); this.props.createAccount({ ...this.state.form }); } @@ -273,7 +279,7 @@ class UtilityAccount extends Component { name={type} className="file" onChange={this.uploadHandler} - disabled={disabled} + disabled={disabled || this.state.disableButtons} />
@@ -595,7 +601,7 @@ class UtilityAccount extends Component { placeholder="password" value={this.state.form.password} onChange={this.handleInputChange} - disabled={this.state.disabled} + disabled={this.state.accountCreated} />
@@ -603,13 +609,15 @@ class UtilityAccount extends Component { ); } return ( - ++ +
); } @@ -626,7 +634,7 @@ class UtilityAccount extends Component { placeholder="username" value={this.state.form.username} onChange={this.handleInputChange} - disabled={this.state.disabled} + disabled={this.state.accountCreated} />@@ -635,7 +643,7 @@ class UtilityAccount extends Component { placeholder="password" value={this.state.form.password} onChange={this.handleInputChange} - disabled={this.state.disabled} + disabled={this.state.accountCreated} />
@@ -644,7 +652,7 @@ class UtilityAccount extends Component { placeholder="access code" value={this.state.form.access_code} onChange={this.handleInputChange} - disabled={this.state.disabled || false} + disabled={this.state.accountCreated || false} />
@@ -666,7 +674,7 @@ class UtilityAccount extends Component { name="utility" value={this.state.form.utility} onChange={this.handleInputChange} - disabled={this.state.disabled} + disabled={this.state.accountCreated} > @@ -679,14 +687,12 @@ class UtilityAccount extends Component { -- {this.renderUtility()} -
+ {this.renderUtility()} {this.renderNatGrid()}- {this.state.disabled && this.renderFetchBtn()} - {!this.state.disabled ? + {this.state.accountCreated && this.renderFetchBtn()} + {!this.state.accountCreated ? this.renderAddAccountBtn() : this.renderDeleteAccountBtn()}
{this.showAccountWarning()} @@ -695,15 +701,15 @@ class UtilityAccount extends Component {