diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js
index dffc38bd1fbda9f4d8f5742c95e0adc84b6d2913..55268b529c4f1a8da89c67ccdc60b6dd13a17ba7 100644
--- a/src/containers/BGroup/BGroup.js
+++ b/src/containers/BGroup/BGroup.js
@@ -28,7 +28,7 @@ import userPropType from '../User/propTypes';
import request from '../../utils/request';
import {
getHeaders, accountURL, gatewayURL,
- contactsURL, sfBuildingImpactURL,
+ contactsURL, sfBuildingImpactURL, heatPumpScoresURL,
} from '../../utils/restServices';
import './styles.css';
@@ -56,6 +56,9 @@ export class BGroup extends Component {
projectStatusBreakdown: {},
contactAccounts: {},
contactParentAccounts: {},
+ heatPumpScoresLoading: false,
+ heatPumpError: false,
+ heatPumpScores: {},
contactLoading: false,
contactError: false,
impactLoading: false,
@@ -83,6 +86,7 @@ export class BGroup extends Component {
if (this.props.user.permissions['read::Gateway']) {
this.getGatewayDates(buildingIds);
}
+ this.getHeatPumpScores(buildingIds);
this.getSimulationDates(buildingIds);
this.getSfBuildingImpact(buildingIds);
if (nextProps.user.permissions['read::CustomImpact']) {
@@ -161,6 +165,52 @@ export class BGroup extends Component {
}
+ getHeatPumpScores = (buildingIds) => {
+ // A function to get all of the contact information for buildings
+ this.setState({ heatPumpScoresLoading: true });
+ const filterString = buildingIds.reduce((acc, val) => (
+ `${acc}building_ids[]=${val}&`
+ ), '');
+ request(`${heatPumpScoresURL}?${filterString}`, {
+ method: 'GET',
+ headers: getHeaders(),
+ }).then((res) => {
+ // Dummy data for building Group: 26 in Dev
+ // const data = res.data;
+ this.setState({ heatPumpScoresLoading: false });
+ const data = [
+ { building_id: 1189745, score: 50 },
+ { building_id: 1189744, score: 40 },
+ { building_id: 1189743, score: 30 },
+ { building_id: 1189742, score: 20 },
+ { building_id: 1189741, score: 10 },
+ ];
+
+ if (!res.err && data) {
+ const heatPumpScores = data.reduce((acc, val) => {
+ if (!acc[val.building_id]) {
+ acc[val.building_id] = [];
+ }
+
+ acc[val.building_id].push(val.score);
+ return acc;
+ }, {});
+ this.setState({ heatPumpScores });
+ } else {
+ // this.setState({ heatPumpError: true });
+ const heatPumpScores = data.reduce((acc, val) => {
+ if (!acc[val.building_id]) {
+ acc[val.building_id] = [];
+ }
+
+ acc[val.building_id].push(val.score);
+ return acc;
+ }, {});
+ this.setState({ heatPumpScores });
+ }
+ });
+ }
+
getContacts = (projects) => {
// A function to get all of the contact information for buildings
this.setState({ contactLoading: true });
@@ -347,15 +397,18 @@ export class BGroup extends Component {
utilityAccountsStatus={this.state.utilityAccountsStatus}
gatewayDates={this.state.gatewayDates}
simulationDates={this.state.simulationDates}
+ heatPumpScores={this.state.heatPumpScores}
contactAccounts={this.state.contactAccounts}
contactParentAccounts={this.state.contactParentAccounts}
impact={this.state.impact}
+ heatPumpScoresLoading={this.state.heatPumpScoresLoading}
contactLoading={this.state.contactLoading}
utilityLoading={this.state.utilityLoading}
simulationLoading={this.state.simulationLoading}
gatewayLoading={this.state.gatewayLoading}
impactLoading={this.state.impactLoading}
displayToggleColumns={this.props.displayToggleColumns}
+ toggleScores={this.props.toggleScores}
toggleContacts={this.props.toggleContacts}
toggleAnalysis={this.props.toggleAnalysis}
toggleProjects={this.props.toggleProjects}
@@ -454,6 +507,7 @@ BGroup.propTypes = {
displayAllGroupsButton: PropTypes.bool,
displayEditButton: PropTypes.bool,
displayToggleColumns: PropTypes.bool,
+ toggleScores: PropTypes.bool,
toggleContacts: PropTypes.bool,
toggleAnalysis: PropTypes.bool,
toggleProjects: PropTypes.bool,
@@ -469,6 +523,7 @@ BGroup.defaultProps = {
displayAllGroupsButton: true,
displayEditButton: true,
displayToggleColumns: true,
+ toggleScores: true,
toggleContacts: false,
toggleAnalysis: true,
toggleProjects: true,
diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js
index 3faf0c211b164f4049a611861458d77d7474d4fb..5f90f4028d5f5d7ca4b04f0187b124a0508904a7 100644
--- a/src/containers/BGroup/BGroupBuildingTable.js
+++ b/src/containers/BGroup/BGroupBuildingTable.js
@@ -21,6 +21,7 @@ export default class BGroupBuildingTable extends Component {
// This relies on the fact that bgroup has already loaded
// when this component is allowed to mount
numRows: this.props.bGroup.bGroupBuildings.length,
+ displayScores: this.props.toggleScores,
displayContact: this.props.toggleContacts,
displayAnalysis: this.props.toggleAnalysis,
displayProjects: this.props.toggleProjects,
@@ -75,9 +76,11 @@ export default class BGroupBuildingTable extends Component {
utilityAccountsStatus,
gatewayDates,
simulationDates,
+ heatPumpScores,
contactAccounts,
contactParentAccounts,
impact,
+ scoresLoading,
contactLoading,
utilityLoading,
simulationLoading,
@@ -330,7 +333,30 @@ export default class BGroupBuildingTable extends Component {
),
}],
],
- }, ...(!this.state.displayContact) ? [] : [{
+ }, ...(!this.state.displayScores) ? [] : [{
+ Header: () => (
+
+ Scores{' '}
+