diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index a5cf9a18a5b42290260d726cac308b4c75e718b2..424eb48f1f2f097f1c0b0224828f7b14e012ba00 100644 --- a/src/components/Utilities/index.js +++ b/src/components/Utilities/index.js @@ -44,6 +44,7 @@ class Utilities extends Component { username: account.login, password: account.pass, access_code: account.access_code, + usage_type: account.usage_type, }, account.id, account.bill_database_output, @@ -168,7 +169,14 @@ class Utilities extends Component { */ const allAccounts = this.state.accountLines.slice(); allAccounts.pop(); - allAccounts.push(this.createUtilityComponent(form, res.data.id)); + const newForm = {}; + // Copy the form properties to a new object so we can update it + Object.keys(form).map((val) => { + newForm[val] = form[val]; + return val; + }); + newForm.usage_type = res.data.usage_type; + allAccounts.push(this.createUtilityComponent(newForm, res.data.id)); allAccounts.push(this.createUtilityComponent()); this.setState({ accountLines: allAccounts }); this.resetErrorMessage(); diff --git a/src/components/UtilityAccount/index.js b/src/components/UtilityAccount/index.js index 443769589837589007df8a51858d734278f2c5f7..9128ab541f82b4792313521d9c6a4a4bc1efc5dc 100644 --- a/src/components/UtilityAccount/index.js +++ b/src/components/UtilityAccount/index.js @@ -15,6 +15,7 @@ class UtilityAccount extends Component { username: this.props.form.username, password: this.props.form.password, access_code: this.props.form.access_code, + usage_type: this.props.form.usage_type, }, account_id: this.props.account_id, billData: this.props.billData, @@ -63,6 +64,7 @@ class UtilityAccount extends Component { }, }) ) + downloadSVG = (event) => { event.preventDefault(); const chartWrapper = document.getElementsByClassName(this.state.account_id)[0]; @@ -288,7 +290,6 @@ class UtilityAccount extends Component { ); } - renderFetchBtn = () => { if (this.state.form.utility.startsWith('other')) { return ( @@ -315,6 +316,15 @@ class UtilityAccount extends Component { ) + renderDeleteAccountBtn = () => ( + + ) + renderBillButtons = () => { const { billData, disaggregateData } = this.state; @@ -578,6 +588,27 @@ class UtilityAccount extends Component { return (
); } + renderDisaggregateDropdown = () => ( + ( +

+ +

+ ) + ) + renderUtility = () => { // Bills with no scrapers do not need account numbers inputted if (this.state.form.utility.startsWith('other')) { @@ -689,12 +720,13 @@ class UtilityAccount extends Component {

{this.renderUtility()} {this.renderNatGrid()} + {this.renderDisaggregateDropdown()}
-

+

{this.state.accountCreated && this.renderFetchBtn()} {!this.state.accountCreated ? this.renderAddAccountBtn() : this.renderDeleteAccountBtn()} -

+
{this.showAccountWarning()}
@@ -738,6 +770,7 @@ UtilityAccount.propTypes = { access_code: PropTypes.string, username: PropTypes.string, password: PropTypes.string, + usage_type: PropTypes.string, }), account_id: PropTypes.number, billData: PropTypes.arrayOf( @@ -774,6 +807,7 @@ UtilityAccount.defaultProps = { access_code: '', username: '', password: '', + usage_type: '', }, account_id: null, disaggregateData: [],