From 85451fba8c168dc27c9038e8d664d754efe89c0b Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Tue, 27 Feb 2018 10:49:52 -0500 Subject: [PATCH 01/19] Add disaggregated data proptypes --- .../UtilityAccountSummary.js | 0 src/components/UtilityLine/UtilityLine.js | 17 +++++--------- src/components/UtilityLine/propTypes.js | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+), 11 deletions(-) rename src/components/{ => UtilityLine}/UtilityAccountSummary.js (100%) create mode 100644 src/components/UtilityLine/propTypes.js diff --git a/src/components/UtilityAccountSummary.js b/src/components/UtilityLine/UtilityAccountSummary.js similarity index 100% rename from src/components/UtilityAccountSummary.js rename to src/components/UtilityLine/UtilityAccountSummary.js diff --git a/src/components/UtilityLine/UtilityLine.js b/src/components/UtilityLine/UtilityLine.js index d7d79448..2129243e 100644 --- a/src/components/UtilityLine/UtilityLine.js +++ b/src/components/UtilityLine/UtilityLine.js @@ -10,7 +10,8 @@ import { uploadSVG } from '../bpl'; import './styles.css'; import { generateBillDownload, renderBillData, renderDisaggregateData } from './dataInteraction'; import userPropType from '../../containers/User/propTypes'; -import UtilityAccountSummary from '../UtilityAccountSummary'; +import UtilityAccountSummary from './UtilityAccountSummary'; +import { disaggregateDataPropTypes } from './propTypes'; class UtilityLine extends Component { @@ -791,7 +792,9 @@ class UtilityLine extends Component {
{this.state.accountCreated && 'Account Summary'}
- +
@@ -860,15 +863,7 @@ UtilityLine.propTypes = { total_charge_bill: PropTypes.number, }) ), - disaggregateData: PropTypes.arrayOf( - PropTypes.shape({ - bill_from_date: PropTypes.string, - bill_to_date: PropTypes.string, - heating: PropTypes.number, - cooling: PropTypes.number, - other: PropTypes.number, - }) - ), + disaggregateData: disaggregateDataPropTypes, accountCreated: PropTypes.bool, street_address: PropTypes.string, createAccount: PropTypes.func, diff --git a/src/components/UtilityLine/propTypes.js b/src/components/UtilityLine/propTypes.js new file mode 100644 index 00000000..54c76cdd --- /dev/null +++ b/src/components/UtilityLine/propTypes.js @@ -0,0 +1,22 @@ +import PropTypes from 'prop-types'; + +const { string, number, shape, arrayOf } = PropTypes; + +const disaggregatedBill = { + bill_from_date: string, + bill_to_date: string, + heating: number, + cooling: number, + other: number, + cooking: number, + dhw: number, + lighting: number, + miscellaneous: number, + plug_load: number, +}; + +export const disaggregateDataPropTypes = arrayOf( + shape({ + ...disaggregatedBill, + }) +); -- GitLab From 5cf43ec06187b212c5d4d19c42f8c62e847f3b21 Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Tue, 27 Feb 2018 15:56:34 -0500 Subject: [PATCH 02/19] Add func toTitleCase and roundNum --- src/utils/formatting.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/utils/formatting.js diff --git a/src/utils/formatting.js b/src/utils/formatting.js new file mode 100644 index 00000000..4f935a55 --- /dev/null +++ b/src/utils/formatting.js @@ -0,0 +1,19 @@ +/** + * Convert `snake_case` to `Title case` + * + * @param {String} str + */ +export function toTitleCase(str) { + return str.split('_') + .map(w => w[0].toUpperCase() + w.substr(1).toLowerCase()) + .join(' '); +} + +/** + * Rounds number to two decimal places + * + * @param {Number} n + */ +export function roundNum(n) { + return Number(n.toFixed(2)); +} -- GitLab From c2e20fa57866c7530785ce6822f1a73d691f8dff Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Tue, 27 Feb 2018 15:56:48 -0500 Subject: [PATCH 03/19] Fix spacing in disaggreagtion component --- src/components/UtilityLine/UtilityDisaggregation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/UtilityLine/UtilityDisaggregation.js b/src/components/UtilityLine/UtilityDisaggregation.js index 3b324fbc..f7a77527 100644 --- a/src/components/UtilityLine/UtilityDisaggregation.js +++ b/src/components/UtilityLine/UtilityDisaggregation.js @@ -298,7 +298,7 @@ class UtilityDisaggregation extends Component { return ( -
+