diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js
index 211dbeee6984edb6871566d4a546501cb4909f6c..ac3060f9d2c11d347283da1cb3ae7ee2efb295a3 100644
--- a/src/containers/BGroup/BGroup.js
+++ b/src/containers/BGroup/BGroup.js
@@ -3,12 +3,12 @@ import { connect } from 'react-redux';
import { Link, browserHistory } from 'react-router';
import { bindActionCreators } from 'redux';
import PropTypes from 'prop-types';
-import { Button, Nav, NavItem, NavLink } from 'reactstrap';
-import ReactTable from 'react-table';
+import {
+ Button, Nav, NavItem, NavLink,
+} from 'reactstrap';
import 'react-table/react-table.css';
import { Icon } from 'react-fa';
import ReactGA from 'react-ga';
-import ReactTooltip from 'react-tooltip';
import Loading from '../../components/Loading';
import NavBar from '../../components/NavBar';
import {
@@ -19,12 +19,13 @@ import {
deleteBGroup,
} from './actions';
import BGroupProjectOverview from './BGroupProjectOverview';
+import BGroupBuildingTable from './BGroupBuildingTable';
import completeProjectPropTypes from '../Project/propTypes';
import { loadProjects } from '../Project/actions';
-import AddressSearch from '../../components/AddressSearch/AddressSearch';
import userPropType from '../User/propTypes';
import request from '../../utils/request';
-import { getHeaders, accountURL, gatewayURL, contactsURL } from '../../utils/restServices';
+import { getHeaders, accountURL, gatewayURL, contactsURL, sfBuildingImpactURL } from '../../utils/restServices';
+import './styles.css';
const UTILITY_TYPES = {
1: 'electric',
@@ -36,7 +37,6 @@ const UTILITY_TYPES = {
/* eslint-disable no-param-reassign */
export class BGroup extends Component {
state = {
- edit: false,
utilityAccountsStatus: {},
utilityLoading: false,
utilityError: false,
@@ -51,11 +51,12 @@ export class BGroup extends Component {
projectStatusBreakdown: {},
contactAccounts: {},
contactParentAccounts: {},
- contactNames: {},
contactLoading: false,
contactError: false,
- numRows: -1,
- overviewTab: this.props.user.permissions['view::bgroupProjectsSummary'] ? 'projects' : 'buildings',
+ impactLoading: false,
+ impactError: false,
+ impact: {},
+ overviewTab: this.props.user.permissions['view::bgroupProjectsSummary'] && this.props.displayProjectOverview ? 'projects' : 'buildings',
}
componentDidMount() {
@@ -72,13 +73,13 @@ export class BGroup extends Component {
val.building_id
));
if (buildingIds.length > 0) {
- this.setState({ numRows: buildingIds.length });
this.props.loadProjects({ 'building_id[]': buildingIds });
this.getUtilityAccounts(buildingIds);
if (this.props.user.permissions['read::Gateway']) {
this.getGatewayDates(buildingIds);
}
this.getSimulationDates(buildingIds);
+ this.getSfBuildingImpact(buildingIds);
}
}
if (
@@ -118,6 +119,27 @@ export class BGroup extends Component {
clearTimeout(this.updateNumRows);
}
+ getSfBuildingImpact = (buildingIds) => {
+ // A function to determine dates of gateway install
+ this.setState({ impactLoading: true });
+ const filterString = buildingIds.reduce((acc, val) => (
+ `${acc}building_id[]=${val}&`
+ ), '');
+ request(`${sfBuildingImpactURL}?${filterString}`, {
+ method: 'GET',
+ headers: getHeaders(),
+ }).then((res) => {
+ this.setState({ impactLoading: false });
+ const data = res.data;
+ if (!res.err && data) {
+ this.setState({ impact: data });
+ } else {
+ this.setState({ impactError: true });
+ }
+ });
+
+ }
+
getContacts = (projects) => {
// A function to get all of the contact information for buildings
this.setState({ contactLoading: true });
@@ -143,15 +165,13 @@ export class BGroup extends Component {
if (!res.err && data) {
const contactAccounts = {};
const contactParentAccounts = {};
- const contactNames = {};
data.map((val) => {
const buildingId = salesForceToBuilding[val.sales_force_id];
contactAccounts[buildingId] = val.account_name;
contactParentAccounts[buildingId] = val.parent_account_name;
- contactNames[buildingId] = val.contacts.map(contact => contact.name);
return val;
});
- this.setState({ contactAccounts, contactParentAccounts, contactNames });
+ this.setState({ contactAccounts, contactParentAccounts });
} else {
this.setState({ contactError: true });
}
@@ -242,23 +262,6 @@ export class BGroup extends Component {
});
}
- handleAddBuilding = (item) => {
- this.props.addBuildingToBGroup(
- this.props.params.bGroupId,
- { building_ids: [item.building_id] },
- item.street_address,
- );
- }
-
- handleDeleteBuilding = (buildingId) => {
- if (confirm('Are you sure you want to delete this building from this group?')) {
- this.props.deleteBuildingFromBGroup(
- this.props.params.bGroupId,
- buildingId,
- );
- }
- }
-
handleDeleteGroup = () => {
const { name } = this.props.bGroup.bGroupDetail;
if (confirm(`Are you sure you want to delete group ${name}? This action cannot be undone.`)) {
@@ -273,7 +276,7 @@ export class BGroup extends Component {
}
if (this.state.edit) {
return (
-
+