From eaf79b0f76742d326f363841ada836dfc87254d9 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 21 Feb 2017 11:26:07 -0500 Subject: [PATCH 1/3] Fix for the empty account number field in add new Utility --- src/components/UtilityAccount/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/UtilityAccount/index.js b/src/components/UtilityAccount/index.js index a9eec87f..1924fe5f 100644 --- a/src/components/UtilityAccount/index.js +++ b/src/components/UtilityAccount/index.js @@ -43,7 +43,11 @@ class UtilityAccount extends Component { handleCreateAccount = (event) => { event.preventDefault(); - this.setState({ disabled: true }); + if (this.state.form.account_number === '') { + this.setState({ disabled: false }); + } else { + this.setState({ disabled: true }); + } this.props.createAccount({ ...this.state.form }); } -- GitLab From 253be7f468b457adb9d7cdb449b798e33f4dd112 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Tue, 21 Feb 2017 11:40:37 -0500 Subject: [PATCH 2/3] The add button on add utility is disabled if account number field is empty --- src/components/UtilityAccount/index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/UtilityAccount/index.js b/src/components/UtilityAccount/index.js index 1924fe5f..23699c6b 100644 --- a/src/components/UtilityAccount/index.js +++ b/src/components/UtilityAccount/index.js @@ -43,11 +43,7 @@ class UtilityAccount extends Component { handleCreateAccount = (event) => { event.preventDefault(); - if (this.state.form.account_number === '') { - this.setState({ disabled: false }); - } else { - this.setState({ disabled: true }); - } + this.setState({ disabled: true }); this.props.createAccount({ ...this.state.form }); } @@ -59,6 +55,7 @@ class UtilityAccount extends Component { renderAddAccountBtn = () => ( - ) + renderAddAccountBtn = () => { + let isDisabled = !(this.state.form.account_number); + if (this.state.form.utility === 'national_grid_gas') { + isDisabled = !(this.state.form.account_number && this.state.form.access_code) + && !(this.state.form.account_number && this.state.form.username && this.state.form.password); + } + return ( + + ); + } renderFetchAndDownloadBtn = () => { const { downloadURL } = this.state; -- GitLab