From cabc60ff41152457964ef30eec08f3e9b6aae99b Mon Sep 17 00:00:00 2001
From: Conrad S
Date: Tue, 2 May 2017 15:50:48 -0400
Subject: [PATCH 1/4] Add 'other' utility types for arbitrary bill upload
---
src/components/UtilityAccount/index.js | 57 ++++++++++++++++++--------
1 file changed, 40 insertions(+), 17 deletions(-)
diff --git a/src/components/UtilityAccount/index.js b/src/components/UtilityAccount/index.js
index ce71dc24..e34ace24 100644
--- a/src/components/UtilityAccount/index.js
+++ b/src/components/UtilityAccount/index.js
@@ -172,7 +172,9 @@ class UtilityAccount extends Component {
}
renderAddAccountBtn = () => {
- let isDisabled = !(this.state.form.account_number);
+ let isDisabled = (
+ !(this.state.form.account_number) && !this.state.form.utility.startsWith('other')
+ );
if (this.state.form.utility === 'national_grid_gas') {
isDisabled = !(
this.state.form.account_number && this.state.form.access_code
@@ -229,15 +231,22 @@ class UtilityAccount extends Component {
}
- renderFetchBtn = () => (
-
- )
+ renderFetchBtn = () => {
+ if (this.state.form.utility.startsWith('other')) {
+ return (
+
+ );
+ }
+ return (
+
+ );
+ }
renderDeleteAccountBtn = () => (
);
}
+ renderUtility = () => {
+ // Bills with no scrapers do not need account numbers inputted
+ if (this.state.form.utility.startsWith('other')) {
+ return ;
+ }
+ return (
+
+ );
+ }
+
renderNatGrid = () => {
if (this.state.form.utility !== 'national_grid_gas') {
return ;
@@ -568,16 +593,14 @@ class UtilityAccount extends Component {
+
+
+
+
-
+ {this.renderUtility()}
{this.renderNatGrid()}
--
GitLab
From 3bbb6799fdd59e01552436fc6885b9fab014ff81 Mon Sep 17 00:00:00 2001
From: Conrad S
Date: Tue, 2 May 2017 16:12:34 -0400
Subject: [PATCH 2/4] Delete by account_id
---
src/components/Utilities/index.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js
index 36eacf7c..0dc7d2fd 100644
--- a/src/components/Utilities/index.js
+++ b/src/components/Utilities/index.js
@@ -232,16 +232,15 @@ class Utilities extends Component {
deleteAccountLine = (accountLineToRemove) => {
const accounts = this.state.accountLines;
- const accountNumberToRemove = accountLineToRemove.state.form.account_number;
const accountIdToRemove = accountLineToRemove.state.account_id;
- request(`${accountURL}${this.props.buildingId}?account_number=${accountNumberToRemove}&account_id=${accountIdToRemove}`, {
+ request(`${accountURL}${accountIdToRemove}`, {
method: 'DELETE',
headers: getHeaders(),
}).then((res) => {
if (!res.err) {
const newAccounts = accounts.filter(account => (
- account.props.form.account_number !== accountNumberToRemove
+ account.props.account_id !== accountIdToRemove
));
this.setState({ accountLines: newAccounts });
--
GitLab
From 6dfd9feaeec895ca2f59cfb6d38635eb91c8b2f4 Mon Sep 17 00:00:00 2001
From: Conrad S
Date: Wed, 3 May 2017 17:25:54 -0400
Subject: [PATCH 3/4] Change wording if bill cannot be scraped
---
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 e34ace24..a080f18a 100644
--- a/src/components/UtilityAccount/index.js
+++ b/src/components/UtilityAccount/index.js
@@ -277,7 +277,11 @@ class UtilityAccount extends Component {
if (scrapeKey) {
scrapeText = 'Loading scraped bill..';
} else {
- scrapeText = 'No scraped bill. Try fetching';
+ if (this.state.form.utility.startsWith('other')) {
+ scrapeText = 'No scraped bill. Upload a bill';
+ } else {
+ scrapeText = 'No scraped bill. Try fetching';
+ }
}
}
if (disaggregateVisibility === 'hidden') {
--
GitLab
From a58cad28ffecf2bdcd7fbde7303f6079bb14078e Mon Sep 17 00:00:00 2001
From: Conrad S
Date: Wed, 3 May 2017 17:39:41 -0400
Subject: [PATCH 4/4] Update if statement
---
src/components/UtilityAccount/index.js | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/components/UtilityAccount/index.js b/src/components/UtilityAccount/index.js
index a080f18a..469a0a34 100644
--- a/src/components/UtilityAccount/index.js
+++ b/src/components/UtilityAccount/index.js
@@ -276,12 +276,10 @@ class UtilityAccount extends Component {
if (scrapeVisibility === 'hidden') {
if (scrapeKey) {
scrapeText = 'Loading scraped bill..';
+ } else if (this.state.form.utility.startsWith('other')) {
+ scrapeText = 'No scraped bill. Upload a bill';
} else {
- if (this.state.form.utility.startsWith('other')) {
- scrapeText = 'No scraped bill. Upload a bill';
- } else {
- scrapeText = 'No scraped bill. Try fetching';
- }
+ scrapeText = 'No scraped bill. Try fetching';
}
}
if (disaggregateVisibility === 'hidden') {
--
GitLab