From 54afbd43b16196f2b1f3b29d21eedf5d350e305d Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 30 Mar 2020 20:34:05 -0400 Subject: [PATCH 01/32] add search bar --- src/containers/BGroup/BGroupBuildingTable.js | 6 +++++- src/containers/SearchBarBGroup/actions.js | 10 +++++----- src/containers/SearchBarBGroup/index.js | 21 ++++++++++++-------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index a3961b93..a0b1e512 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -39,6 +39,8 @@ export default class BGroupBuildingTable extends Component { } handleAddBuilding = (item) => { + console.log(item); + console.log(this.props.buildings); this.props.addBuildingToBGroup( this.props.bGroupId, { building_ids: [item.building_id] }, @@ -872,7 +874,9 @@ export default class BGroupBuildingTable extends Component { > Search and add address   - +
= 0 ? '' : 'none' }}> diff --git a/src/containers/SearchBarBGroup/actions.js b/src/containers/SearchBarBGroup/actions.js index 623714c8..72a4fcc2 100644 --- a/src/containers/SearchBarBGroup/actions.js +++ b/src/containers/SearchBarBGroup/actions.js @@ -21,9 +21,9 @@ export function searchBuildings(address) { } // TODO: Add doctring -export function buildingsSearched(buildings, args) { - if (args) { - const address = `Address searched: ${args.address}`; +export function buildingsSearched(buildings, address) { + if (address) { + console.log(address); if (buildings.length > 0) { ReactGA.event({ category: 'Search', action: 'Success', label: `${address}` }); } else { @@ -37,8 +37,8 @@ export function buildingsSearched(buildings, args) { } // TODO: Add doctring -export function buildingsSearchingError(error, args) { - ReactGA.event({ category: 'Search', action: 'Error', label: `Searched for ${args.address}, Failed due to ${error}` }); +export function buildingsSearchingError(error, address) { + ReactGA.event({ category: 'Search', action: 'Error', label: `Searched for ${address}, Failed due to ${error}` }); return { type: SEARCH_BUILDINGS_ERROR, error, diff --git a/src/containers/SearchBarBGroup/index.js b/src/containers/SearchBarBGroup/index.js index d3a48cf9..f6bbf2fa 100644 --- a/src/containers/SearchBarBGroup/index.js +++ b/src/containers/SearchBarBGroup/index.js @@ -35,18 +35,18 @@ class SearchBar extends Component { componentDidMount() { // Use the buildings stored in cookies to populate the buildingList - const buildingList = localStorage.activeBuildings; - if (buildingList !== undefined) { - this.props.buildingsSearched(JSON.parse(buildingList)); + const buildings = localStorage.activeBuildings; + if (buildings !== undefined) { + this.props.buildingsSearched(JSON.parse(buildings)); } } componentWillReceiveProps(nextProps) { if ( - this.props.buildingList !== nextProps.buildingList + this.props.buildings !== nextProps.buildings ) { this.setState({ - address: nextProps.buildingList.address, + address: nextProps.buildings.address, }); } } @@ -58,6 +58,10 @@ class SearchBar extends Component { addressFound: true, }, () => { this.props.searchBuildings(this.state.address); + console.log(this.props.buildings); + if (this.props.buildings !== undefined) { + this.props.addSelectedAddress(this.props.buildings); + } }); } @@ -119,9 +123,10 @@ class SearchBar extends Component { } SearchBar.propTypes = { - buildingList: buildingListPropTypes, + buildings: buildingListPropTypes, searchBuildings: PropTypes.func, buildingsSearched: PropTypes.func, + addSelectedAddress: PropTypes.func, }; function mapDispatchToProps(dispatch) { @@ -131,8 +136,8 @@ function mapDispatchToProps(dispatch) { }, dispatch); } -function mapStateToProps({ buildingList }) { - return { buildingList }; +function mapStateToProps({ buildings }) { + return { buildings }; } export default connect(mapStateToProps, mapDispatchToProps)(SearchBar); -- GitLab From 6595bea726bdd4a9a430ca9a8c1aca0a65c4c413 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 31 Mar 2020 12:31:38 -0400 Subject: [PATCH 02/32] Add addressSearch components --- src/components/AddressSearchBGroup/index.js | 122 ++++++++++++++++ src/components/AddressSearchBGroup/styles.css | 133 ++++++++++++++++++ .../AddressSearchBuildings/index.js | 120 ++++++++++++++++ .../AddressSearchBuildings/styles.css | 129 +++++++++++++++++ src/components/BuildingListTable/index.js | 2 + src/containers/BGroup/BGroupBuildingTable.js | 9 +- src/containers/SearchBarBGroup/actions.js | 1 - src/containers/SearchBarBGroup/index.js | 6 +- src/screens/BuildingsHomePage/index.js | 4 +- 9 files changed, 514 insertions(+), 12 deletions(-) create mode 100644 src/components/AddressSearchBGroup/index.js create mode 100644 src/components/AddressSearchBGroup/styles.css create mode 100644 src/components/AddressSearchBuildings/index.js create mode 100644 src/components/AddressSearchBuildings/styles.css diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js new file mode 100644 index 00000000..14673be1 --- /dev/null +++ b/src/components/AddressSearchBGroup/index.js @@ -0,0 +1,122 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import Geocoder from 'react-mapbox-gl-geocoder'; +import { Row, Col, Nav, NavItem } from 'reactstrap'; +import './styles.css'; + + +const mapAccess = { + mapboxApiAccessToken: process.env.REACT_APP_MAPBOX_TOKEN, +}; + +const queryParams = { + country: 'us', +}; + +class AddressSearchBGroup extends Component { + constructor(props) { + super(props); + this.state = { + viewport: {}, + addressFound: false, + address: '', + loadingAddressSearchBtn: false, + disabledAddressSearchBtn: true, + subscribed: false, + }; + } + + componentDidMount() { + // Use the buildings stored in cookies to populate the buildingList + const buildings = localStorage.activeBuildings; + if (buildings !== undefined) { + this.props.buildingsSearched(JSON.parse(buildings)); + } + } + + componentWillReceiveProps(nextProps) { + if ( + this.props.buildings !== nextProps.buildings + ) { + this.setState({ + address: nextProps.buildings.address, + }); + } + } + + handleOnSelected = (viewport, item) => { + this.setState({ + viewport, + address: item.place_name, + addressFound: true, + }, () => { + this.props.addSelectedAddress(this.state.address); + }); + } + + handleOnChange = (event) => { + this.setState({ + address: event.target.value, + addressFound: false, + }); + } + + render() { + let addressData = ''; + const { viewport } = this.state; + if (this.state.addressFound === false) { + addressData = ( + + ); + } else { + addressData = ( + + ); + } + + const content = ( +
+ + + {addressData} + + +
+ ); + + return ( + + ); + } +} + +AddressSearchBGroup.propTypes = { + buildings: PropTypes.objectOf, + searchBuildings: PropTypes.func, + buildingsSearched: PropTypes.func, + addSelectedAddress: PropTypes.func, +}; + + +export default AddressSearchBGroup; diff --git a/src/components/AddressSearchBGroup/styles.css b/src/components/AddressSearchBGroup/styles.css new file mode 100644 index 00000000..ae86686a --- /dev/null +++ b/src/components/AddressSearchBGroup/styles.css @@ -0,0 +1,133 @@ + +.building-search { + background-color: #222; + padding: 40px; +} + +.input-group { + width: inherit !important; +} + +.btn.dropdown-toggle:hover { + background-color: #E9E4E4 !important; +} + +.dropdown-selection { + height: 100%; + display: table-cell; + vertical-align: middle; + background-color: white; + border-top-right-radius: 0.25rem; + border-bottom-right-radius: 0.25rem; + line-height: 1.5; + padding-top: 0.5rem; + padding-right: 0.75rem; + padding-bottom: 0.5rem; + padding-left: 0.75rem; +} + +li.navbar-input { + -webkit-padding-start: 20px; +} + +li.navbar-input>form { + height: 100%; +} + +.pr-1 { + margin-top: 0.5rem; +} + +.addressSearchInputBGroup { + width: 750px !important; + position: relative; + padding-left: '15px'; + margin-top: '2px'; +} + +.addressSearchInputBGroup .addressDisplay { + height: 35px; + font-size: 14px; + width: 100% !important; + padding: 10px; + margin-top: 5px; + margin-bottom: 5px; +} + +.addressSearchInputBGroup .react-geocoder { + position: relative; +} + +.addressSearchInputBGroup .react-geocoder input { + height: 35px; + width: 100% !important; + padding: 5px; + margin-top: 5px; + margin-bottom: 5px; + font-size: 14px; +} + +.addressSearchInputBGroup .react-geocoder-results { + background: #FFFFFF; + width: 100% !important; +} + +.addressSearchInputBGroup .react-geocoder-item { + width: 100% !important; + margin-left: 0px; + height: auto !important; + border-bottom: 0.5px solid #EEEEEE !important; + border-left: 0.5px solid #EEEEEE !important; + border-right: 0.5px solid #EEEEEE !important; + height: 30px !important; + padding: 1% 2% 4% 2% !important; + font-size: 14px !important; + margin-left: 0px; + cursor: pointer; + color: #000000; + overflow: visible; + position: relative; +} + +.addressSearchInputBGroup .react-geocoder-item:hover { + border-bottom: 0.5px solid #DDDDDD !important; + cursor: pointer; + background: #EEEEEE; +} + +@media screen and (max-width: 992px) { + .addressSearchInputBGroup { + width: 600px !important; + } + .addressSearchInputBGroup .react-geocoder-item { + font-size: 13px !important; + font-weight: normal; + } + .addressSearchInputBGroup .react-geocoder input { + font-size: 13px !important; + font-weight: normal; + } + .addressSearchInputBGroup .addressDisplay { + height: 35px; + font-size: 13px; + } +} + +@media screen and (max-width: 600px) { + .addressSearchInputBGroup { + width: 335px !important; + margin-bottom: 15px; + } + .addressSearchInputBGroup .react-geocoder-item { + font-size: 11px !important; + font-weight: normal; + } + .addressSearchInputBGroup .react-geocoder input { + font-size: 11px !important; + font-weight: normal; + } + .addressSearchInputBGroup .addressDisplay { + height: 35px; + font-size: 11px; + } +} diff --git a/src/components/AddressSearchBuildings/index.js b/src/components/AddressSearchBuildings/index.js new file mode 100644 index 00000000..f2465456 --- /dev/null +++ b/src/components/AddressSearchBuildings/index.js @@ -0,0 +1,120 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import Geocoder from 'react-mapbox-gl-geocoder'; +import { Row, Col, Nav, NavItem } from 'reactstrap'; +import './styles.css'; + + +const mapAccess = { + mapboxApiAccessToken: process.env.REACT_APP_MAPBOX_TOKEN, +}; + +const queryParams = { + country: 'us', +}; + +class AddressSearchBuildings extends Component { + constructor(props) { + super(props); + this.state = { + viewport: {}, + addressFound: false, + address: '', + loadingAddressSearchBtn: false, + disabledAddressSearchBtn: true, + subscribed: false, + }; + } + + componentDidMount() { + // Use the buildings stored in cookies to populate the buildingList + const buildingList = localStorage.activeBuildings; + if (buildingList !== undefined) { + this.props.buildingsSearched(JSON.parse(buildingList)); + } + } + + componentWillReceiveProps(nextProps) { + if ( + this.props.buildingList !== nextProps.buildingList + ) { + this.setState({ + address: nextProps.buildingList.address, + }); + } + } + + handleOnSelected = (viewport, item) => { + this.setState({ + viewport, + address: item.place_name, + addressFound: true, + }, () => { + this.props.searchBuildings(this.state.address); + }); + } + + handleOnChange = (event) => { + this.setState({ + address: event.target.value, + addressFound: false, + }); + } + + render() { + let addressData = ''; + const { viewport } = this.state; + if (this.state.addressFound === false) { + addressData = ( + + ); + } else { + addressData = ( + + ); + } + + const content = ( +
+ + + {addressData} + + +
+ ); + + return ( + + ); + } +} + +AddressSearchBuildings.propTypes = { + buildingList: PropTypes.objectOf, + searchBuildings: PropTypes.func, + buildingsSearched: PropTypes.func, +}; + +export default AddressSearchBuildings; diff --git a/src/components/AddressSearchBuildings/styles.css b/src/components/AddressSearchBuildings/styles.css new file mode 100644 index 00000000..68410717 --- /dev/null +++ b/src/components/AddressSearchBuildings/styles.css @@ -0,0 +1,129 @@ + +.building-search { + background-color: #222; + padding: 40px; +} + +.input-group { + width: inherit !important; +} + +.btn.dropdown-toggle:hover { + background-color: #E9E4E4 !important; +} + +.dropdown-selection { + height: 100%; + display: table-cell; + vertical-align: middle; + background-color: white; + border-top-right-radius: 0.25rem; + border-bottom-right-radius: 0.25rem; + line-height: 1.5; + padding-top: 0.5rem; + padding-right: 0.75rem; + padding-bottom: 0.5rem; + padding-left: 0.75rem; +} + +li.navbar-input { + -webkit-padding-start: 20px; +} + +li.navbar-input>form { + height: 100%; +} + +.addressSearchInputBuildings { + width: 700px !important; + position: relative; + padding-left: '15px'; + margin-top: '2px'; +} + +.addressSearchInputBuildings .addressDisplay { + height: 35px; + font-size: 16px; + font-weight: bold; + width: 100% !important; + padding: 10px; + margin-top: 5px; + margin-bottom: 5px; +} + +.addressSearchInputBuildings .react-geocoder { + position: relative; +} + +.addressSearchInputBuildings .react-geocoder input { + height: 35px; + width: 100% !important; + padding: 5px; + margin-top: 5px; + margin-bottom: 5px; + font-weight: bold; + font-size: 16px; +} + +.addressSearchInputBuildings .react-geocoder-results { + position: absolute; + background: #333333; + width: 100% !important; +} + +.addressSearchInputBuildings .react-geocoder-item { + width: 100% !important; + margin-left: 0px; + height: auto !important; + border-bottom: 0.5px solid rgba(160, 160, 160, .5) !important; + height: 30px !important; + font-weight: 700; + padding: 1% 2% 5% 2% !important; + font-size: 16px !important; + margin-left: 0px; + cursor: pointer; + color: #DDDDDD; + overflow: visible; + position: relative; +} + +.addressSearchInputBuildings .react-geocoder-item:hover { + color: #FFFFFF; + border-bottom: 0.5px solid #555555 !important; +} + +@media screen and (max-width: 992px) { + .addressSearchInput { + width: 600px !important; + } + .react-geocoder-item { + font-size: 13px !important; + font-weight: normal; + } + .react-geocoder input { + font-size: 13px !important; + font-weight: normal; + } + .addressDisplay { + height: 35px; + font-size: 13px; + } +} + +@media screen and (max-width: 600px) { + .addressSearchInput { + width: 420px !important; + } + .react-geocoder-item { + font-size: 11px !important; + font-weight: normal; + } + .react-geocoder input { + font-size: 11px !important; + font-weight: normal; + } + .addressDisplay { + height: 35px; + font-size: 11px; + } +} diff --git a/src/components/BuildingListTable/index.js b/src/components/BuildingListTable/index.js index 34d2d899..bea73890 100644 --- a/src/components/BuildingListTable/index.js +++ b/src/components/BuildingListTable/index.js @@ -110,6 +110,8 @@ export default function BuildingListTable({ return acc; }, {}); + console.log(buildings); // eslint-disable-line + const buildingItems = buildings.map((building) => { let bblTd = (); if (building.bbl in lotGrouping || !bblDisplay) { diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index a0b1e512..165a7be2 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -14,7 +14,8 @@ import { import userPropTypes from '../User/propTypes'; import SearchBar from '../SearchBarBGroup'; import completeProjectPropTypes from '../Project/propTypes'; -// import buildingPropTypes from '../Building/propTypes'; +import buildingPropTypes from '../Building/propTypes'; + /* eslint-disable no-param-reassign */ export default class BGroupBuildingTable extends Component { @@ -39,8 +40,8 @@ export default class BGroupBuildingTable extends Component { } handleAddBuilding = (item) => { - console.log(item); - console.log(this.props.buildings); + console.log(item); // eslint-disable-line + console.log(this.props.buildings); // eslint-disable-line this.props.addBuildingToBGroup( this.props.bGroupId, { building_ids: [item.building_id] }, @@ -1076,7 +1077,7 @@ BGroupBuildingTable.propTypes = { edit: PropTypes.bool, bGroupId: PropTypes.string, user: userPropTypes, - // buildings: buildingPropTypes, + buildings: buildingPropTypes, projects: completeProjectPropTypes, addBuildingToBGroup: PropTypes.func, deleteBuildingFromBGroup: PropTypes.func, diff --git a/src/containers/SearchBarBGroup/actions.js b/src/containers/SearchBarBGroup/actions.js index 72a4fcc2..55f2c261 100644 --- a/src/containers/SearchBarBGroup/actions.js +++ b/src/containers/SearchBarBGroup/actions.js @@ -23,7 +23,6 @@ export function searchBuildings(address) { // TODO: Add doctring export function buildingsSearched(buildings, address) { if (address) { - console.log(address); if (buildings.length > 0) { ReactGA.event({ category: 'Search', action: 'Success', label: `${address}` }); } else { diff --git a/src/containers/SearchBarBGroup/index.js b/src/containers/SearchBarBGroup/index.js index f6bbf2fa..b5d0a8cf 100644 --- a/src/containers/SearchBarBGroup/index.js +++ b/src/containers/SearchBarBGroup/index.js @@ -57,11 +57,7 @@ class SearchBar extends Component { address: item.place_name, addressFound: true, }, () => { - this.props.searchBuildings(this.state.address); - console.log(this.props.buildings); - if (this.props.buildings !== undefined) { - this.props.addSelectedAddress(this.props.buildings); - } + this.props.addSelectedAddress(this.state.address); }); } diff --git a/src/screens/BuildingsHomePage/index.js b/src/screens/BuildingsHomePage/index.js index 6dacc26f..de58f882 100644 --- a/src/screens/BuildingsHomePage/index.js +++ b/src/screens/BuildingsHomePage/index.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import NavBar from '../../components/NavBar'; -import SearchBar from '../../containers/SearchBarBuildings'; +import AddressSearchBuildings from '../../components/AddressSearchBuildings'; import BuildingListTable from '../../components/BuildingListTable'; import { buildingListPropTypes } from '../../containers/SearchBarBuildings/propTypes'; import { @@ -24,7 +24,7 @@ class BuildingsHomePage extends Component { return (
{ const buildingList = localStorage.activeBuildings; if (buildingList !== undefined) { -- GitLab From 5d01e41d8392cdd6573905b663bc4874ab8aefaa Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 31 Mar 2020 12:56:33 -0400 Subject: [PATCH 03/32] Fix buildings page not loading buildings issue --- src/components/NavBar/index.js | 5 +++++ src/screens/BuildingsHomePage/index.js | 1 + 2 files changed, 6 insertions(+) diff --git a/src/components/NavBar/index.js b/src/components/NavBar/index.js index 008167fc..dac34c4c 100644 --- a/src/components/NavBar/index.js +++ b/src/components/NavBar/index.js @@ -27,6 +27,9 @@ export default class NavBar extends Component { this.setState({ collapsed }) ) + buildingsSearched = buildings => ( + this.props.buildingsSearched(buildings) + ) toggleNavbar = () => ( this.setState({ @@ -54,6 +57,7 @@ export default class NavBar extends Component { {this.props.SearchBar ? : null} -- GitLab From 23658bbba14df7ee5390a4c36effb505b5239da4 Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Wed, 1 Apr 2020 14:46:26 -0400 Subject: [PATCH 07/32] add button show and hide --- src/containers/BGroup/BGroupBuildingTable.js | 3 ++- src/containers/SearchBarBGroup/index.js | 26 ++++++++++++-------- src/containers/SearchBarBGroup/styles.css | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index 165a7be2..e120057a 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -12,9 +12,10 @@ import { UncontrolledTooltip, } from 'reactstrap'; import userPropTypes from '../User/propTypes'; -import SearchBar from '../SearchBarBGroup'; import completeProjectPropTypes from '../Project/propTypes'; import buildingPropTypes from '../Building/propTypes'; +// import SearchBar from '../../components/AddressSearchBGroup'; +import SearchBar from '../SearchBarBGroup'; /* eslint-disable no-param-reassign */ diff --git a/src/containers/SearchBarBGroup/index.js b/src/containers/SearchBarBGroup/index.js index 1067f262..fb619702 100644 --- a/src/containers/SearchBarBGroup/index.js +++ b/src/containers/SearchBarBGroup/index.js @@ -28,8 +28,8 @@ class SearchBar extends Component { addressFound: false, address: '', loadingAddressSearchBtn: false, - disabledAddressSearchBtn: true, subscribed: false, + showAddButton: false, }; } @@ -56,7 +56,7 @@ class SearchBar extends Component { viewport, address: item.place_name, addressFound: true, - disabledAddressSearchBtn: false, + showAddButton: true, }, () => { this.props.addSelectedAddress(this.state.address); }); @@ -66,12 +66,13 @@ class SearchBar extends Component { this.setState({ address: event.target.value, addressFound: false, - disabledAddressSearchBtn: true, + showAddButton: false, }); } render() { let addressData = ''; + let showAddButton = ''; const { viewport } = this.state; if (this.state.addressFound === false) { addressData = ( @@ -90,7 +91,7 @@ class SearchBar extends Component { + +
+ ); + } + const content = (
{addressData} + + {showAddButton} +
); @@ -114,12 +126,6 @@ class SearchBar extends Component {
{content}
-
- -
); diff --git a/src/containers/SearchBarBGroup/styles.css b/src/containers/SearchBarBGroup/styles.css index ae86686a..31f13e04 100644 --- a/src/containers/SearchBarBGroup/styles.css +++ b/src/containers/SearchBarBGroup/styles.css @@ -130,4 +130,4 @@ li.navbar-input>form { height: 35px; font-size: 11px; } -} +} \ No newline at end of file -- GitLab From e34435138780499349c21ea50794a96f85b2cbae Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Wed, 1 Apr 2020 17:21:38 -0400 Subject: [PATCH 08/32] refactored --- src/containers/BGroup/BGroupBuildingTable.js | 1 - src/containers/SearchBarBGroup/index.js | 6 +++--- src/containers/SearchBarBGroup/styles.css | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index e120057a..da2ce3e5 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -858,7 +858,6 @@ export default class BGroupBuildingTable extends Component { val.projected_deemed_savings = []; val.completed_deemed_savings = []; } - return val; }); diff --git a/src/containers/SearchBarBGroup/index.js b/src/containers/SearchBarBGroup/index.js index fb619702..1716e139 100644 --- a/src/containers/SearchBarBGroup/index.js +++ b/src/containers/SearchBarBGroup/index.js @@ -102,7 +102,9 @@ class SearchBar extends Component { if (this.state.showAddButton === true) { showAddButton = (
- +
); } @@ -112,8 +114,6 @@ class SearchBar extends Component { {addressData} - - {showAddButton} diff --git a/src/containers/SearchBarBGroup/styles.css b/src/containers/SearchBarBGroup/styles.css index 31f13e04..f3f8ff9f 100644 --- a/src/containers/SearchBarBGroup/styles.css +++ b/src/containers/SearchBarBGroup/styles.css @@ -130,4 +130,8 @@ li.navbar-input>form { height: 35px; font-size: 11px; } +} + +.addButtonBGroup { + background-color: #000000; } \ No newline at end of file -- GitLab From 33642b937787acf36fe105b86b3dcfb1ce8df398 Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Wed, 1 Apr 2020 17:51:54 -0400 Subject: [PATCH 09/32] container address search --- src/components/AddressSearchBGroup/index.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 14673be1..6ae16d0e 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -21,8 +21,8 @@ class AddressSearchBGroup extends Component { addressFound: false, address: '', loadingAddressSearchBtn: false, - disabledAddressSearchBtn: true, subscribed: false, + showAddButton: false, }; } @@ -50,10 +50,14 @@ class AddressSearchBGroup extends Component { address: item.place_name, addressFound: true, }, () => { - this.props.addSelectedAddress(this.state.address); + this.props.searchedBuildings(this.state.address); }); } + handleOnAddBuilding = () => { + this.props.addSelectedAddress(); + } + handleOnChange = (event) => { this.setState({ address: event.target.value, @@ -63,6 +67,7 @@ class AddressSearchBGroup extends Component { render() { let addressData = ''; + let showAddButton = ''; const { viewport } = this.state; if (this.state.addressFound === false) { addressData = ( @@ -81,14 +86,19 @@ class AddressSearchBGroup extends Component { + {this.state.showAddButton && + + } ); } - + const content = (
-- GitLab From 07c1cf1beb876470be07d0a18e83e4ce1631c892 Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Wed, 1 Apr 2020 18:00:12 -0400 Subject: [PATCH 10/32] using component instead od a container for search --- src/components/AddressSearchBGroup/index.js | 12 ++++++------ src/containers/BGroup/BGroupBuildingTable.js | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 6ae16d0e..24ecf9a0 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -91,14 +91,9 @@ class AddressSearchBGroup extends Component { className="addressDisplay" placeholder="Enter building address ..." /> - {this.state.showAddButton && - - } ); } - + const content = (
@@ -114,6 +109,11 @@ class AddressSearchBGroup extends Component {
{content} + {this.state.showAddButton && + + }
diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index da2ce3e5..5f7d41d4 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -14,9 +14,7 @@ import { import userPropTypes from '../User/propTypes'; import completeProjectPropTypes from '../Project/propTypes'; import buildingPropTypes from '../Building/propTypes'; -// import SearchBar from '../../components/AddressSearchBGroup'; -import SearchBar from '../SearchBarBGroup'; - +import SearchBar from '../../components/AddressSearchBGroup'; /* eslint-disable no-param-reassign */ export default class BGroupBuildingTable extends Component { @@ -40,6 +38,10 @@ export default class BGroupBuildingTable extends Component { clearTimeout(this.updateNumRows); } + handleSearchBuilding = (address) => { + this.props.searchedBuildings(address); + } + handleAddBuilding = (item) => { console.log(item); // eslint-disable-line console.log(this.props.buildings); // eslint-disable-line -- GitLab From 50028bf444332988a4cb60b216ac938efde42238 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 1 Apr 2020 18:49:33 -0400 Subject: [PATCH 11/32] Move search bar to reusable container and refactor BGroup building search --- src/components/AddressSearchBGroup/index.js | 33 ++-- src/components/BuildingListTable/index.js | 2 +- src/containers/BGroup/BGroup.js | 8 + .../actions.js | 0 .../constants.js | 0 .../index.js | 0 .../propTypes.js | 0 .../reducer.js | 0 .../ring.svg | 0 .../{SearchBarBGroup => SearchBar}/sagas.js | 0 .../styles.css | 0 src/containers/SearchBarBGroup/actions.js | 45 ------ src/containers/SearchBarBGroup/index.js | 153 ------------------ src/containers/SearchBarBGroup/styles.css | 137 ---------------- .../SearchBarBuildings/constants.js | 5 - .../SearchBarBuildings/propTypes.js | 35 ---- src/containers/SearchBarBuildings/sagas.js | 56 ------- src/reducers.js | 2 +- src/sagas.js | 4 +- src/screens/BuildingsHomePage/index.js | 4 +- 20 files changed, 26 insertions(+), 458 deletions(-) rename src/containers/{SearchBarBuildings => SearchBar}/actions.js (100%) rename src/containers/{SearchBarBGroup => SearchBar}/constants.js (100%) rename src/containers/{SearchBarBuildings => SearchBar}/index.js (100%) rename src/containers/{SearchBarBGroup => SearchBar}/propTypes.js (100%) rename src/containers/{SearchBarBuildings => SearchBar}/reducer.js (100%) rename src/containers/{SearchBarBuildings => SearchBar}/ring.svg (100%) rename src/containers/{SearchBarBGroup => SearchBar}/sagas.js (100%) rename src/containers/{SearchBarBuildings => SearchBar}/styles.css (100%) delete mode 100644 src/containers/SearchBarBGroup/actions.js delete mode 100644 src/containers/SearchBarBGroup/index.js delete mode 100644 src/containers/SearchBarBGroup/styles.css delete mode 100644 src/containers/SearchBarBuildings/constants.js delete mode 100644 src/containers/SearchBarBuildings/propTypes.js delete mode 100644 src/containers/SearchBarBuildings/sagas.js diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 24ecf9a0..be79651b 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Geocoder from 'react-mapbox-gl-geocoder'; -import { Row, Col, Nav, NavItem } from 'reactstrap'; +import { Row, Col, Nav, NavItem, Button } from 'reactstrap'; import './styles.css'; @@ -20,20 +20,10 @@ class AddressSearchBGroup extends Component { viewport: {}, addressFound: false, address: '', - loadingAddressSearchBtn: false, - subscribed: false, showAddButton: false, }; } - componentDidMount() { - // Use the buildings stored in cookies to populate the buildingList - const buildings = localStorage.activeBuildings; - if (buildings !== undefined) { - this.props.buildingsSearched(JSON.parse(buildings)); - } - } - componentWillReceiveProps(nextProps) { if ( this.props.buildings !== nextProps.buildings @@ -49,8 +39,9 @@ class AddressSearchBGroup extends Component { viewport, address: item.place_name, addressFound: true, + showAddButton: true, }, () => { - this.props.searchedBuildings(this.state.address); + this.props.searchBuildings(this.state.address); }); } @@ -62,14 +53,14 @@ class AddressSearchBGroup extends Component { this.setState({ address: event.target.value, addressFound: false, + showAddButton: false, }); } render() { let addressData = ''; - let showAddButton = ''; const { viewport } = this.state; - if (this.state.addressFound === false) { + if (!this.state.addressFound) { addressData = ( {addressData} + {this.state.showAddButton && + + }
@@ -109,11 +107,6 @@ class AddressSearchBGroup extends Component {
{content} - {this.state.showAddButton && - - }
diff --git a/src/components/BuildingListTable/index.js b/src/components/BuildingListTable/index.js index bea73890..9abf1e1b 100644 --- a/src/components/BuildingListTable/index.js +++ b/src/components/BuildingListTable/index.js @@ -3,7 +3,7 @@ import ReactGA from 'react-ga'; import PropTypes from 'prop-types'; import { browserHistory } from 'react-router'; import './styles.css'; -import { buildingList, loadErrorPropTypes } from '../../containers/SearchBarBGroup/propTypes'; +import { buildingList, loadErrorPropTypes } from '../../containers/SearchBar/propTypes'; import Loading from '../../components/Loading'; /* eslint-disable no-param-reassign */ diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index 8e9dc147..b991fb6c 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -18,6 +18,10 @@ import { deleteBuildingFromBGroup, deleteBGroup, } from './actions'; +import { + searchBuildings, + buildingsSearched, +} from '../SearchBar/actions'; // import { loadBuildings } from '../Building/actions'; import BGroupProjectOverview from './BGroupProjectOverview'; import BGroupBuildingTable from './BGroupBuildingTable'; @@ -416,6 +420,7 @@ export class BGroup extends Component { user={this.props.user} projects={this.props.projects} buildings={this.props.buildings} + searchBuildings={this.props.searchBuildings} bGroup={this.props.bGroup} addBuildingToBGroup={this.props.addBuildingToBGroup} deleteBuildingFromBGroup={this.props.deleteBuildingFromBGroup} @@ -516,6 +521,7 @@ BGroup.propTypes = { params: PropTypes.shape({ bGroupId: PropTypes.string, }), + searchBuildings: PropTypes.func, bGroup: PropTypes.object, // eslint-disable-line loadBGroupBuildings: PropTypes.func, loadBGroupDetail: PropTypes.func, @@ -570,6 +576,8 @@ const mapStateToProps = state => ( const mapDispatchToProps = dispatch => ( bindActionCreators({ + searchBuildings, + buildingsSearched, loadBGroupBuildings, loadBGroupDetail, addBuildingToBGroup, diff --git a/src/containers/SearchBarBuildings/actions.js b/src/containers/SearchBar/actions.js similarity index 100% rename from src/containers/SearchBarBuildings/actions.js rename to src/containers/SearchBar/actions.js diff --git a/src/containers/SearchBarBGroup/constants.js b/src/containers/SearchBar/constants.js similarity index 100% rename from src/containers/SearchBarBGroup/constants.js rename to src/containers/SearchBar/constants.js diff --git a/src/containers/SearchBarBuildings/index.js b/src/containers/SearchBar/index.js similarity index 100% rename from src/containers/SearchBarBuildings/index.js rename to src/containers/SearchBar/index.js diff --git a/src/containers/SearchBarBGroup/propTypes.js b/src/containers/SearchBar/propTypes.js similarity index 100% rename from src/containers/SearchBarBGroup/propTypes.js rename to src/containers/SearchBar/propTypes.js diff --git a/src/containers/SearchBarBuildings/reducer.js b/src/containers/SearchBar/reducer.js similarity index 100% rename from src/containers/SearchBarBuildings/reducer.js rename to src/containers/SearchBar/reducer.js diff --git a/src/containers/SearchBarBuildings/ring.svg b/src/containers/SearchBar/ring.svg similarity index 100% rename from src/containers/SearchBarBuildings/ring.svg rename to src/containers/SearchBar/ring.svg diff --git a/src/containers/SearchBarBGroup/sagas.js b/src/containers/SearchBar/sagas.js similarity index 100% rename from src/containers/SearchBarBGroup/sagas.js rename to src/containers/SearchBar/sagas.js diff --git a/src/containers/SearchBarBuildings/styles.css b/src/containers/SearchBar/styles.css similarity index 100% rename from src/containers/SearchBarBuildings/styles.css rename to src/containers/SearchBar/styles.css diff --git a/src/containers/SearchBarBGroup/actions.js b/src/containers/SearchBarBGroup/actions.js deleted file mode 100644 index 55f2c261..00000000 --- a/src/containers/SearchBarBGroup/actions.js +++ /dev/null @@ -1,45 +0,0 @@ -import ReactGA from 'react-ga'; - -import { - SEARCH_BUILDINGS, - SEARCH_BUILDINGS_SUCCESS, - SEARCH_BUILDINGS_ERROR, -} from './constants'; - -/** - * Load the list of buildings, this action starts the request saga - * - * @param {dict} args The args to send to the backend - * @returns {object} An action object with a type of LOAD_BUILDINGS - * and filterName and value - */ -export function searchBuildings(address) { - return { - type: SEARCH_BUILDINGS, - address, - }; -} - -// TODO: Add doctring -export function buildingsSearched(buildings, address) { - if (address) { - if (buildings.length > 0) { - ReactGA.event({ category: 'Search', action: 'Success', label: `${address}` }); - } else { - ReactGA.event({ category: 'Search', action: 'Fail', label: `${address} not found` }); - } - } - return { - type: SEARCH_BUILDINGS_SUCCESS, - payload: buildings, - }; -} - -// TODO: Add doctring -export function buildingsSearchingError(error, address) { - ReactGA.event({ category: 'Search', action: 'Error', label: `Searched for ${address}, Failed due to ${error}` }); - return { - type: SEARCH_BUILDINGS_ERROR, - error, - }; -} diff --git a/src/containers/SearchBarBGroup/index.js b/src/containers/SearchBarBGroup/index.js deleted file mode 100644 index 1716e139..00000000 --- a/src/containers/SearchBarBGroup/index.js +++ /dev/null @@ -1,153 +0,0 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import Geocoder from 'react-mapbox-gl-geocoder'; -import { Row, Col, Nav, NavItem, Button } from 'reactstrap'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; -import { - searchBuildings, - buildingsSearched, -} from './actions'; -import './styles.css'; -import { buildingListPropTypes } from './propTypes'; - - -const mapAccess = { - mapboxApiAccessToken: process.env.REACT_APP_MAPBOX_TOKEN, -}; - -const queryParams = { - country: 'us', -}; - -class SearchBar extends Component { - constructor(props) { - super(props); - this.state = { - viewport: {}, - addressFound: false, - address: '', - loadingAddressSearchBtn: false, - subscribed: false, - showAddButton: false, - }; - } - - componentDidMount() { - // Use the buildings stored in cookies to populate the buildingList - const buildings = localStorage.activeBuildings; - if (buildings !== undefined) { - this.props.buildingsSearched(JSON.parse(buildings)); - } - } - - componentWillReceiveProps(nextProps) { - if ( - this.props.buildings !== nextProps.buildings - ) { - this.setState({ - address: nextProps.buildings.address, - }); - } - } - - handleOnSelected = (viewport, item) => { - this.setState({ - viewport, - address: item.place_name, - addressFound: true, - showAddButton: true, - }, () => { - this.props.addSelectedAddress(this.state.address); - }); - } - - handleOnChange = (event) => { - this.setState({ - address: event.target.value, - addressFound: false, - showAddButton: false, - }); - } - - render() { - let addressData = ''; - let showAddButton = ''; - const { viewport } = this.state; - if (this.state.addressFound === false) { - addressData = ( - - ); - } else { - addressData = ( - - ); - } - - if (this.state.showAddButton === true) { - showAddButton = ( -
- -
- ); - } - - const content = ( -
- - - {addressData} - {showAddButton} - - -
- ); - - return ( - - ); - } -} - -SearchBar.propTypes = { - buildings: buildingListPropTypes, - searchBuildings: PropTypes.func, - buildingsSearched: PropTypes.func, - addSelectedAddress: PropTypes.func, -}; - -function mapDispatchToProps(dispatch) { - return bindActionCreators({ - searchBuildings, - buildingsSearched, - }, dispatch); -} - -function mapStateToProps({ buildings }) { - return { buildings }; -} - -export default connect(mapStateToProps, mapDispatchToProps)(SearchBar); diff --git a/src/containers/SearchBarBGroup/styles.css b/src/containers/SearchBarBGroup/styles.css deleted file mode 100644 index f3f8ff9f..00000000 --- a/src/containers/SearchBarBGroup/styles.css +++ /dev/null @@ -1,137 +0,0 @@ - -.building-search { - background-color: #222; - padding: 40px; -} - -.input-group { - width: inherit !important; -} - -.btn.dropdown-toggle:hover { - background-color: #E9E4E4 !important; -} - -.dropdown-selection { - height: 100%; - display: table-cell; - vertical-align: middle; - background-color: white; - border-top-right-radius: 0.25rem; - border-bottom-right-radius: 0.25rem; - line-height: 1.5; - padding-top: 0.5rem; - padding-right: 0.75rem; - padding-bottom: 0.5rem; - padding-left: 0.75rem; -} - -li.navbar-input { - -webkit-padding-start: 20px; -} - -li.navbar-input>form { - height: 100%; -} - -.pr-1 { - margin-top: 0.5rem; -} - -.addressSearchInputBGroup { - width: 750px !important; - position: relative; - padding-left: '15px'; - margin-top: '2px'; -} - -.addressSearchInputBGroup .addressDisplay { - height: 35px; - font-size: 14px; - width: 100% !important; - padding: 10px; - margin-top: 5px; - margin-bottom: 5px; -} - -.addressSearchInputBGroup .react-geocoder { - position: relative; -} - -.addressSearchInputBGroup .react-geocoder input { - height: 35px; - width: 100% !important; - padding: 5px; - margin-top: 5px; - margin-bottom: 5px; - font-size: 14px; -} - -.addressSearchInputBGroup .react-geocoder-results { - background: #FFFFFF; - width: 100% !important; -} - -.addressSearchInputBGroup .react-geocoder-item { - width: 100% !important; - margin-left: 0px; - height: auto !important; - border-bottom: 0.5px solid #EEEEEE !important; - border-left: 0.5px solid #EEEEEE !important; - border-right: 0.5px solid #EEEEEE !important; - height: 30px !important; - padding: 1% 2% 4% 2% !important; - font-size: 14px !important; - margin-left: 0px; - cursor: pointer; - color: #000000; - overflow: visible; - position: relative; -} - -.addressSearchInputBGroup .react-geocoder-item:hover { - border-bottom: 0.5px solid #DDDDDD !important; - cursor: pointer; - background: #EEEEEE; -} - -@media screen and (max-width: 992px) { - .addressSearchInputBGroup { - width: 600px !important; - } - .addressSearchInputBGroup .react-geocoder-item { - font-size: 13px !important; - font-weight: normal; - } - .addressSearchInputBGroup .react-geocoder input { - font-size: 13px !important; - font-weight: normal; - } - .addressSearchInputBGroup .addressDisplay { - height: 35px; - font-size: 13px; - } -} - -@media screen and (max-width: 600px) { - .addressSearchInputBGroup { - width: 335px !important; - margin-bottom: 15px; - } - .addressSearchInputBGroup .react-geocoder-item { - font-size: 11px !important; - font-weight: normal; - } - .addressSearchInputBGroup .react-geocoder input { - font-size: 11px !important; - font-weight: normal; - } - .addressSearchInputBGroup .addressDisplay { - height: 35px; - font-size: 11px; - } -} - -.addButtonBGroup { - background-color: #000000; -} \ No newline at end of file diff --git a/src/containers/SearchBarBuildings/constants.js b/src/containers/SearchBarBuildings/constants.js deleted file mode 100644 index b0a679aa..00000000 --- a/src/containers/SearchBarBuildings/constants.js +++ /dev/null @@ -1,5 +0,0 @@ -export const FETCH_BUILDINGS = 'FETCH_BUILDINGS'; -export const UPDATE_BUILDING_SEARCH_PARAMS = 'UPDATE_BUILDING_SEARCH_PARAMS'; -export const SEARCH_BUILDINGS = 'SEARCH_BUILDINGS'; -export const SEARCH_BUILDINGS_SUCCESS = 'SEARCH_BUILDINGS_SUCCESS'; -export const SEARCH_BUILDINGS_ERROR = 'SEARCH_BUILDINGS_ERROR'; diff --git a/src/containers/SearchBarBuildings/propTypes.js b/src/containers/SearchBarBuildings/propTypes.js deleted file mode 100644 index 2eafabea..00000000 --- a/src/containers/SearchBarBuildings/propTypes.js +++ /dev/null @@ -1,35 +0,0 @@ -import PropTypes from 'prop-types'; - -const { string, number, bool, shape, arrayOf, oneOfType } = PropTypes; - -export const loadErrorPropTypes = { - loading: bool, - error: oneOfType([ - bool, - PropTypes.instanceOf(Error), - ]), -}; - -export const buildingList = arrayOf( - shape({ - street_address: string, - bbl: number, - bin: number, - building_id: number, - lot_id: number, - borough_id: number, - zipcode: string, - }) -); - -export const searchParams = shape({ - type: string, - borough: string, - term: string, -}); - -export const buildingListPropTypes = PropTypes.shape({ - ...searchParams, - buildings: buildingList, - ...loadErrorPropTypes, -}); diff --git a/src/containers/SearchBarBuildings/sagas.js b/src/containers/SearchBarBuildings/sagas.js deleted file mode 100644 index d74337fe..00000000 --- a/src/containers/SearchBarBuildings/sagas.js +++ /dev/null @@ -1,56 +0,0 @@ -import { put, takeLatest } from 'redux-saga/effects'; -// import request from '../../utils/request'; -// import { getHeaders, buildingsURL } from '../../utils/restServices'; - -import { - SEARCH_BUILDINGS, -} from './constants'; - -import { - buildingsSearched, - buildingsSearchingError, -} from './actions'; - -/** - * TODO: doctring - */ -function* getBuildingsByFilter(action) { - const placeName = action.address; - // const res = yield call( - // request, - // `${buildingsURL}?$place_name=${placeName}limit=300`, { - // method: 'GET', - // headers: getHeaders(), - // } - // ); - - // For now, we commented out http call and hard coded the response data - const res = { - data: [ - { - bbl: 3012410005, - bin: 3031524, - borough: 'BROOKLYN', - building_id: 181794, - lot_id: 759242, - street_address: '838 PARK PLACE', - targeting_score: 73.9496248660236, - zipcode: '11216', - placeName, - }, - ], - }; - - if (!res.err) { - yield put(buildingsSearched(res.data, placeName)); - } else { - yield put(buildingsSearchingError(res.err, placeName)); - } -} - -/** - * TODO: docstring - */ -export default function* buildingsWatcher() { - yield takeLatest(SEARCH_BUILDINGS, getBuildingsByFilter); -} diff --git a/src/reducers.js b/src/reducers.js index ab87b302..1cf26cca 100644 --- a/src/reducers.js +++ b/src/reducers.js @@ -1,7 +1,7 @@ import { combineReducers } from 'redux'; import { routerReducer } from 'react-router-redux'; -import SearchBarReducer from './containers/SearchBarBuildings/reducer'; +import SearchBarReducer from './containers/SearchBar/reducer'; import ProjectSearchBarReducer from './containers/Project/reducer'; import BuildingReducer from './containers/Building/reducer'; import DimensionsReducer from './containers/Dimensions/reducer'; diff --git a/src/sagas.js b/src/sagas.js index cb7dca6e..364d621a 100644 --- a/src/sagas.js +++ b/src/sagas.js @@ -1,7 +1,6 @@ import buildingSaga from './containers/Building/sagas'; import dimensionsSaga from './containers/Dimensions/sagas'; -import buildingsSearchSaga from './containers/SearchBarBuildings/sagas'; -import bGroupSearchSaga from './containers/SearchBarBGroup/sagas'; +import buildingsSearchSaga from './containers/SearchBar/sagas'; import projectsSearchSaga from './containers/Project/sagas'; import reportsSaga from './containers/Reports/sagas'; import documentsSaga from './containers/Documents/sagas'; @@ -24,7 +23,6 @@ export default function* rootSaga() { buildingSaga(), dimensionsSaga(), buildingsSearchSaga(), - bGroupSearchSaga(), projectsSearchSaga(), documentsSaga(), engSaga(), diff --git a/src/screens/BuildingsHomePage/index.js b/src/screens/BuildingsHomePage/index.js index 7811619d..23e5c100 100644 --- a/src/screens/BuildingsHomePage/index.js +++ b/src/screens/BuildingsHomePage/index.js @@ -5,11 +5,11 @@ import { bindActionCreators } from 'redux'; import NavBar from '../../components/NavBar'; import AddressSearchBuildings from '../../components/AddressSearchBuildings'; import BuildingListTable from '../../components/BuildingListTable'; -import { buildingListPropTypes } from '../../containers/SearchBarBuildings/propTypes'; +import { buildingListPropTypes } from '../../containers/SearchBar/propTypes'; import { searchBuildings, buildingsSearched, -} from '../../containers/SearchBarBuildings/actions'; +} from '../../containers/SearchBar/actions'; import userPropType from '../../containers/User/propTypes'; import NotAuthorized from '../../components/NotAuthorized'; -- GitLab From 4ce53b5cd7944b538a9fd3c6d041f4a490f23ba5 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 1 Apr 2020 18:59:34 -0400 Subject: [PATCH 12/32] add addBuildingToGroup event --- src/components/AddressSearchBGroup/index.js | 2 +- src/components/ProjectListTable/index.js | 2 +- src/containers/BGroup/BGroup.js | 1 + src/containers/BGroup/BGroupBuildingTable.js | 12 +- .../BGroup/BGroupBuildingTable.js.bak | 1110 +++++++++++++++++ 5 files changed, 1119 insertions(+), 8 deletions(-) create mode 100644 src/containers/BGroup/BGroupBuildingTable.js.bak diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index be79651b..605dda65 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -93,7 +93,7 @@ class AddressSearchBGroup extends Component { {this.state.showAddButton && } diff --git a/src/components/ProjectListTable/index.js b/src/components/ProjectListTable/index.js index 3406f705..670fe9c4 100644 --- a/src/components/ProjectListTable/index.js +++ b/src/components/ProjectListTable/index.js @@ -3,7 +3,7 @@ import ReactGA from 'react-ga'; import PropTypes from 'prop-types'; import { browserHistory } from 'react-router'; import './styles.css'; -import { loadErrorPropTypes } from '../../containers/SearchBarBuildings/propTypes'; +import { loadErrorPropTypes } from '../../containers/SearchBar/propTypes'; import { projectPropTypes } from '../../containers/Project/propTypes'; import Loading from '../../components/Loading'; diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index b991fb6c..21a4b8c3 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -420,6 +420,7 @@ export class BGroup extends Component { user={this.props.user} projects={this.props.projects} buildings={this.props.buildings} + // searchedBuildings={this.props.searchedBuildings} searchBuildings={this.props.searchBuildings} bGroup={this.props.bGroup} addBuildingToBGroup={this.props.addBuildingToBGroup} diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index 5f7d41d4..59e41395 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -14,7 +14,7 @@ import { import userPropTypes from '../User/propTypes'; import completeProjectPropTypes from '../Project/propTypes'; import buildingPropTypes from '../Building/propTypes'; -import SearchBar from '../../components/AddressSearchBGroup'; +import AddressSearchBGroup from '../../components/AddressSearchBGroup'; /* eslint-disable no-param-reassign */ export default class BGroupBuildingTable extends Component { @@ -38,13 +38,11 @@ export default class BGroupBuildingTable extends Component { clearTimeout(this.updateNumRows); } - handleSearchBuilding = (address) => { - this.props.searchedBuildings(address); + handleSearchBuildings = (address) => { + this.props.searchBuildings(address); } handleAddBuilding = (item) => { - console.log(item); // eslint-disable-line - console.log(this.props.buildings); // eslint-disable-line this.props.addBuildingToBGroup( this.props.bGroupId, { building_ids: [item.building_id] }, @@ -877,7 +875,8 @@ export default class BGroupBuildingTable extends Component { > Search and add address   -
@@ -1081,6 +1080,7 @@ BGroupBuildingTable.propTypes = { user: userPropTypes, buildings: buildingPropTypes, projects: completeProjectPropTypes, + searchBuildings: PropTypes.func, addBuildingToBGroup: PropTypes.func, deleteBuildingFromBGroup: PropTypes.func, /* eslint-disable react/forbid-prop-types */ diff --git a/src/containers/BGroup/BGroupBuildingTable.js.bak b/src/containers/BGroup/BGroupBuildingTable.js.bak new file mode 100644 index 00000000..5f7d41d4 --- /dev/null +++ b/src/containers/BGroup/BGroupBuildingTable.js.bak @@ -0,0 +1,1110 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import ReactTable from 'react-table'; +import ReactTooltip from 'react-tooltip'; +import { Link } from 'react-router'; +import { Icon } from 'react-fa'; +import ReactGA from 'react-ga'; +import { CSVLink } from 'react-csv'; +import { + Input, Collapse, UncontrolledDropdown, + DropdownToggle, DropdownMenu, DropdownItem, + UncontrolledTooltip, +} from 'reactstrap'; +import userPropTypes from '../User/propTypes'; +import completeProjectPropTypes from '../Project/propTypes'; +import buildingPropTypes from '../Building/propTypes'; +import SearchBar from '../../components/AddressSearchBGroup'; + +/* eslint-disable no-param-reassign */ +export default class BGroupBuildingTable extends Component { + state = { + edit: false, + // This relies on the fact that bgroup has already loaded + // when this component is allowed to mount + numRows: this.props.bGroup.bGroupBuildings.length, + totalRows: this.props.bGroup.bGroupBuildings, + displayScores: this.props.toggleScores, + displayContact: this.props.toggleContacts, + displayAnalysis: this.props.toggleAnalysis, + displayProjects: this.props.toggleProjects, + displayImpact: this.props.toggleImpact, + recommendedRetrofitsToggle: {}, + recommendedDeemedToggle: {}, + completedDeemedToggle: {}, + }; + + componentWillUnmount() { + clearTimeout(this.updateNumRows); + } + + handleSearchBuilding = (address) => { + this.props.searchedBuildings(address); + } + + handleAddBuilding = (item) => { + console.log(item); // eslint-disable-line + console.log(this.props.buildings); // eslint-disable-line + this.props.addBuildingToBGroup( + this.props.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.bGroupId, + buildingId, + ); + } + } + + + renderDeleteBuildingButton = (id) => { + if (this.props.bGroup.deleteBGroupBuildingLoading[id]) { + return ( + + ); + } + const disabled = !this.props.user.permissions['delete::BuildingBGroup']; + return ( + (this.handleDeleteBuilding(id))} + style={{ cursor: disabled ? 'not-allowed' : 'pointer' }} + disabled={disabled} + /> + ); + } + + render() { + const { + buildingIdProject, + utilityAccountsStatus, + gatewayDates, + simulationDates, + bbls, + heatPumpScores, + contactAccounts, + contactParentAccounts, + impact, + scoresLoading, + contactLoading, + utilityLoading, + simulationLoading, + gatewayLoading, + impactLoading, + } = this.props; + + let { bGroupBuildings } = this.props.bGroup; + // A generic filter method that ensures that empty rows return false + const genericFilterMethod = (filter, row) => ( + row[filter.id] ? + row[filter.id].toLowerCase().indexOf( // eslint-disable-line + filter.value.toLowerCase() + ) !== -1 + : false + ); + + const listFilterMethod = (filter, row) => { + if (row[filter.id]) { + + return row[filter.id].reduce((acc, val) => ( + val && (acc || val.toLowerCase().indexOf( + filter.value.toLowerCase() + ) !== -1) + ), false); + } + return false; + }; + + const utilityBillFilterMethod = (filter, row) => { + if (filter.value === 'all') { + return true; + } + if (filter.value === 'received') { + return row[filter.id]; + } + return !row[filter.id]; + }; + + const impactRecommendedFilterMethod = (filter, row) => { + if (filter.value === 'all') { + return true; + } + if (filter.value === 'delivered') { + return row[filter.id].length > 0; + } + return row[filter.id].length === 0; + }; + + const impactCompletedFilterMethod = (filter, row) => { + if (filter.value === 'all') { + return true; + } + if (filter.value === 'completed') { + return row[filter.id].length > 0; + } + return row[filter.id].length === 0; + }; + + const impactCompletedRetrofitsFilterMethod = (filter, row) => { + // First check if there is a value and the check box is clicked + if ( + filter.value.check && + (!row[filter.id] || !row[filter.id].length > 0) + ) { + return false; + } + // Then filter by text + if (row[filter.id]) { + // Check if list is empty + if (filter.value.query === '' && row[filter.id].length === 0) { + return true; + } + return row[filter.id].reduce((acc, val) => ( + val && (acc || val.completed.toLowerCase().indexOf( + filter.value.query.toLowerCase() + ) !== -1) + ), false); + } + return false; + }; + + const impactRecommendedRetrofitsFilterMethod = (filter, row) => { + // First check if there is a value and the check box is clicked + if ( + filter.value.check && + (!row[filter.id] || !row[filter.id].length > 0) + ) { + return false; + } + // Then filter by text + if (row[filter.id]) { + // Check if list is empty + if (filter.value.query === '' && row[filter.id].length === 0) { + return true; + } + return row[filter.id].reduce((acc, val) => ( + val && (acc || val.toLowerCase().indexOf( + filter.value.query.toLowerCase() + ) !== -1) + ), false); + } + return false; + }; + + const utilityBillFilter = ({ filter, onChange }) => ( + + ); + + const impactRecommendedFilter = ({ filter, onChange }) => ( + + ); + + const impactCompletedFilter = ({ filter, onChange }) => ( + + ); + + const impactCompletedRetrofitsFilter = ({ filter, onChange }) => { + return ( +
+ onChange({ + query: event.target.value, + check: filter ? filter.value.check : false, + })} + value={filter ? filter.value.query : ''} + style={{ width: '75px' }} + /> + {' '} +
+ { + onChange({ + query: filter ? filter.value.query : '', + check: filter ? !filter.value.check : true, + }); + }} + /> +
+ + Only show buildings with completed retrofits + +
+ ); + }; + + const impactRecommendedRetrofitsFilter = ({ filter, onChange }) => { + return ( +
+ onChange({ + query: event.target.value, + check: filter ? filter.value.check : false, + })} + value={filter ? filter.value.query : ''} + style={{ width: '75px' }} + /> + {' '} +
+ { + onChange({ + query: filter ? filter.value.query : '', + check: filter ? !filter.value.check : true, + }); + }} + /> +
+ + Only show buildings with recommended retrofits + +
+ ); + }; + + + const columns = [{ + Header: () => ( + + Building Info{' '} + + + ), + columns: [ + { + Header: 'Address', + filterMethod: (filter, row) => ( + row._original.address_list.toLowerCase().indexOf( // eslint-disable-line + filter.value.toLowerCase() + ) !== -1 + ), + Filter: ({ filter, onChange }) => ( + onChange(event.target.value)} + /> + ), + accessor: 'first_address', + Cell: row => ( +
+ {row.value} +
+ ), + }, + ...(!this.props.user.permissions['view::bgroupBblColumn']) ? [] : [{ + Header: 'BBL', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'bbl', + Cell: row => ( +
+ {row.value} +
+ ), + }], + ], + }, ...(!this.state.displayScores) ? [] : [{ + Header: () => ( + + Scores{' '} + + + ), + columns: [ + { + Header: 'Heat Pump', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'heat_pump_score', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: 'Building Proximities', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'building_proximities', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: 'Fuel Type', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'fuel_type', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: 'Owner Occupied', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'owner_occupied', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: 'Stable Ownership', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'stable_ownership', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: 'Age of Building', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'building_age', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: 'Pre War/Post War', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'pre_post_war', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: '# of 311 Complaints', + filterable: true, + style: { textAlign: 'center' }, + accessor: 'complaint_311', + Cell: row => ( +
+ {row.value} +
+ ), + }, + ], + }], ...(!this.state.displayContact) ? [] : [{ + Header: () => ( + + Contact Info{' '} + + + ), + columns: [ + { + Header: 'Owner', + filterMethod: genericFilterMethod, + accessor: 'contact_account', + Cell: row => ( +
+ {row.value} +
+ ), + }, { + Header: 'Parent Company', + filterMethod: genericFilterMethod, + accessor: 'contact_parent_account', + Cell: row => ( +
+ {row.value} +
+ ), + }, + ], + }], ...(!this.state.displayAnalysis) ? [] : [{ + Header: () => ( + + Analysis{' '} + + + ), + columns: [ + { + Header: 'Electric Bill', + filterMethod: utilityBillFilterMethod, + Filter: utilityBillFilter, + accessor: 'electric_bill', + style: { textAlign: 'center' }, + Cell: row => ( + row.value ? : null + ), + }, { + Header: 'Gas Bill', + filterMethod: utilityBillFilterMethod, + Filter: utilityBillFilter, + accessor: 'gas_bill', + style: { textAlign: 'center' }, + Cell: row => ( + row.value ? : null + ), + }, { + Header: 'Energy Simulation', + filterMethod: (filter, row) => { + if (filter.value === 'all') { + return true; + } + if (filter.value === 'complete') { + return row[filter.id]; + } + return !row[filter.id]; + }, + Filter: ({ filter, onChange }) => ( + + ), + accessor: 'building_simulation', + style: { textAlign: 'center' }, + Cell: row => ( + row.value ? : null + ), + }, + ], + }], ...(!this.state.displayProjects) ? [] : [{ + Header: () => ( + + Projects{' '} + + + ), + columns: [ + // Only show the sensor install column if the user has the correct permission + ...(!this.props.user.permissions['read::Gateway']) ? [] : [{ + Header: 'Sensor Install', + filterMethod: (filter, row) => { + if (filter.value === 'all') { + return true; + } + if (filter.value === 'installed') { + return row[filter.id]; + } + return !row[filter.id]; + }, + Filter: ({ filter, onChange }) => ( + + ), + accessor: 'gateway_install', + sortMethod: (a, b) => { + if (!b && a) { + return 1; + } else if (b && !a) { + return -1; + } else if (!b && !a) { + return 0; + } + const d1 = new Date(a[0]); + const d2 = new Date(b[0]); + if (d1.getTime() === d2.getTime()) { + return 0; + } + return d1 > d2 ? 1 : -1; + }, + Cell: row => (row.value ? ( +
+
    + {row.value.map((installDate, index) => ( +
  • {installDate}
  • + ))} +
+
+ ) : null), + }], { + Header: '# Projects', + filterable: false, + style: { textAlign: 'center' }, + accessor: 'num_projects', + }, { + Header: 'Project Types', + filterMethod: listFilterMethod, + accessor: 'project_types', + Cell: row => (row.value ? ( +
+
    + {row.value.map((type, index) => ( +
  • {type}
  • + ))} +
+
+ ) : null), + }, + ], + }], ...(!this.props.user.permissions['read::SfBuildingImpact'] || !this.state.displayImpact) ? [] : [{ + Header: () => ( + + Impact{' '} + + + ), + columns: [ + { + Header: 'Recommended Retrofits', + filterMethod: impactRecommendedRetrofitsFilterMethod, + Filter: impactRecommendedRetrofitsFilter, + accessor: 'recommended_retrofits', + Cell: (row) => { + if (row.value && row.value.length > 0) { + const buildingId = row.original.building_id; + const toggleButton = ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ +
{ + this.setState({ recommendedRetrofitsToggle: { + ...this.state.recommendedRetrofitsToggle, + [buildingId]: !this.state.recommendedRetrofitsToggle[buildingId], + } }); + }} + className="bp-cell-dropdown" + > + {' '} + {this.state.recommendedRetrofitsToggle[buildingId] ? 'Hide' : 'Show'} +
+ ); + return ( +
+ {toggleButton} + +
    + {row.value.map((val, index) => ( +
  • {val}
  • + ))} +
+
+
+ ); + } + return null; + }, + }, { + Header: 'Deemed Savings (recommended)', + filterMethod: impactRecommendedFilterMethod, + Filter: impactRecommendedFilter, + style: { textAlign: 'center' }, + accessor: 'projected_deemed_savings', + Cell: (row) => { + if (row.value && row.value.length > 0) { + const buildingId = row.original.building_id; + const toggleButton = ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ +
{ + this.setState({ recommendedDeemedToggle: { + ...this.state.recommendedDeemedToggle, + [buildingId]: !this.state.recommendedDeemedToggle[buildingId], + } }); + }} + className="bp-cell-dropdown" + > + {' '} + {this.state.recommendedDeemedToggle[buildingId] ? 'Hide' : 'Show'} +
+ ); + return ( +
+ {toggleButton} + +
    + {row.value.map((val, index) => ( +
  • {val}
  • + ))} +
+
+
+ ); + } + return null; + }, + }, { + Header: 'Completed Retrofits', + filterMethod: impactCompletedRetrofitsFilterMethod, + Filter: impactCompletedRetrofitsFilter, + accessor: 'completed_retrofits', + Cell: row => (row.value ? ( +
+
    + {row.value.map((val, index) => ( +
  • {val.completed} ({(new Date(val.completed_date)).toLocaleDateString('en-US')})
  • + ))} +
+
+ ) : null), + }, { + Header: 'Deemed Savings (completed)', + filterMethod: impactCompletedFilterMethod, + Filter: impactCompletedFilter, + style: { textAlign: 'center' }, + accessor: 'completed_deemed_savings', + Cell: (row) => { + if (row.value && row.value.length > 0) { + const buildingId = row.original.building_id; + const toggleButton = ( + /* eslint-disable jsx-a11y/no-static-element-interactions */ +
{ + this.setState({ completedDeemedToggle: { + ...this.state.completedDeemedToggle, + [buildingId]: !this.state.completedDeemedToggle[buildingId], + } }); + }} + className="bp-cell-dropdown" + > + {' '} + {this.state.completedDeemedToggle[buildingId] ? 'Hide' : 'Show'} +
+ ); + return ( +
+ {toggleButton} + +
    + {row.value.map((val, index) => ( +
  • {val}
  • + ))} +
+
+
+ ); + } + return null; + }, + }, + ], + }]]; + if (this.props.edit) { + columns.push({ + Header: '', + filterable: false, + accessor: 'delete', + maxWidth: 35, + Cell: row => this.renderDeleteBuildingButton(row.original.id), + }); + } + bGroupBuildings = bGroupBuildings.map((val) => { + const projects = buildingIdProject[val.building_id]; + if (projects) { + val.num_projects = projects.length; + val.project_types = projects.map(proj => (proj.project_type)); + val.bbl = projects.reduce((acc, proj) => { + if (!acc && proj.bbl) { + return proj.bbl; + } + return acc; + }, null); + } else { + val.num_projects = 0; + val.project_types = []; + } + const utilityStatus = utilityAccountsStatus[val.building_id]; + if (utilityStatus) { + val.electric_bill = utilityStatus.electric; + val.gas_bill = utilityStatus.gas; + } + val.gateway_install = gatewayDates[val.building_id]; + val.building_simulation = simulationDates[val.building_id]; + val.bbl = bbls[val.building_id]; + console.log("heatPumpScores rendering"); // eslint-disable-line + console.log(heatPumpScores); // eslint-disable-line + if (heatPumpScores[val.building_id]) { + val.heat_pump_score = heatPumpScores[val.building_id].score; + val.building_proximities = heatPumpScores[val.building_id].building_proximities_cost; + val.fuel_type = heatPumpScores[val.building_id].type_of_fuel; + val.owner_occupied = heatPumpScores[val.building_id].owner_occupied; + val.stable_ownership = heatPumpScores[val.building_id].stable_tenure_of_ownership; + val.building_age = heatPumpScores[val.building_id].building_age; + val.pre_post_war = heatPumpScores[val.building_id].pre_post_war; + val.complaint_311 = heatPumpScores[val.building_id].complaint_311; + } else { + val.heat_pump_score = -1; + val.building_proximities = -1; + val.fuel_type = -1; + val.owner_occupied = -1; + val.stable_ownership = -1; + val.building_age = -1; + val.pre_post_war = -1; + val.complaint_311 = -1; + } + // Contact + val.contact_account = contactAccounts[val.building_id]; + val.contact_parent_account = contactParentAccounts[val.building_id]; + // Project Impact + if (impact[val.building_id]) { + const impactObjects = impact[val.building_id]; + if (impactObjects.diagnostic_recommendations.length > 0) { + val.recommended_retrofits = impactObjects.diagnostic_recommendations; + } else { + val.recommended_retrofits = impactObjects.pns_recommendations; + } + val.completed_retrofits = impactObjects.complete; + // Create a list of all of the projected deemed values + val.projected_deemed_savings = Object.keys(impactObjects.deemed.projected).reduce( + (acc, key) => ([ + ...acc, + ...(impactObjects.deemed.projected[key]) ? [`${impactObjects.deemed.projected[key]} ${key.replace('Projected ', '')}`] : [], + ]), [] + ); + // Create a list of all of the completed deemed values + val.completed_deemed_savings = Object.keys(impactObjects.deemed.completed).reduce( + (acc, key) => ([ + ...acc, + ...(impactObjects.deemed.completed[key]) ? [`${impactObjects.deemed.completed[key]} ${key.replace('Completed ', '')}`] : [], + ]), [] + ); + } else { + val.recommended_retrofits = []; + val.completed_retrofits = []; + val.projected_deemed_savings = []; + val.completed_deemed_savings = []; + } + return val; + }); + + const csvlinkStyle = { + lineHeight: 1.15, + }; + + return ( +
+
+
+ + +
+
+
= 0 ? '' : 'none' }}> +
+
{this.state.numRows} buildings
+
+ + Export ⬇ +   + + + Toggle Columns + + + { + this.setState({ displayScores: !this.state.displayScores }); + }} + > + + {}} + />{' '} + Scores + + + { + this.setState({ displayContact: !this.state.displayContact }); + }} + > + + {}} + />{' '} + Contact Info + + + { + this.setState({ displayAnalysis: !this.state.displayAnalysis }); + }} + > + + {}} + />{' '} + Analysis + + + { + this.setState({ displayProjects: !this.state.displayProjects }); + }} + > + + {}} + />{' '} + Projects + + + { + this.setState({ displayImpact: !this.state.displayImpact }); + }} + > + + {}} + />{' '} + Impact + + + + +
+
+
+ { this.reactTable = reactTable; }} + onFilteredChange={(filter) => { + // Create a bounce function so as to not decrease the speed of the filter. + clearTimeout(this.updateNumRows); + this.updateNumRows = setTimeout( + () => { + ReactGA.event({ + category: 'Building Group', + action: 'Filter', + label: filter.reduce((acc, val) => { + return ( + `${acc}, ${val.id}: ${val.value}` + ); + }, `Building Group: ${this.props.bGroup.bGroupDetail.name}, # Results: ${this.reactTable.state.sortedData.length}`), + }); + this.setState({ + numRows: this.reactTable.state.sortedData.length, + totalRows: this.reactTable.state.sortedData.map((item) => { + delete item._index; // eslint-disable-line + delete item._original; // eslint-disable-line + delete item._nestingLevel; // eslint-disable-line + delete item._subRows; // eslint-disable-line + return item; + }), + }); + }, + 250, + ); + this.props.onBuildingFilter(filter, this.reactTable.state); + }} + noDataText={this.props.bGroup.bGroupDetailLoading ? 'Loading...' : 'No data'} + SubComponent={row => { + const addresses = bGroupBuildings + .filter(i => i.building_id === row.original.building_id) + .reduce((acc, val) => val.address_list, '') + .split(','); + return ( +
+ +
+
+

+ Address list{' '} + + + +

+
    + {addresses.map(i =>
  • {i}
  • )} +
+
+ {buildingIdProject[row.original.building_id] ? ( +
+

+ Project list +

+
    + {buildingIdProject[row.original.building_id].map((i) => { + let spanStatus = 'pending'; + if (i.state === 'constructed') { + spanStatus = 'claimed'; + } else if (i.state === 'cancelled') { + spanStatus = 'rejected'; + } + return ( +
  • + { i.state } + {' '} - {i.project_type ? i.project_type : 'Project' } +
  • + ); + })} +
+
+ ) : null} +
+
+ ); + }} + /> +
+
+
+ ); + } +} + +BGroupBuildingTable.propTypes = { + edit: PropTypes.bool, + bGroupId: PropTypes.string, + user: userPropTypes, + buildings: buildingPropTypes, + projects: completeProjectPropTypes, + addBuildingToBGroup: PropTypes.func, + deleteBuildingFromBGroup: PropTypes.func, + /* eslint-disable react/forbid-prop-types */ + bGroup: PropTypes.object, + buildingIdProject: PropTypes.object, + utilityAccountsStatus: PropTypes.object, + gatewayDates: PropTypes.object, + simulationDates: PropTypes.object, + bbls: PropTypes.object, + heatPumpScores: PropTypes.object, + contactAccounts: PropTypes.object, + contactParentAccounts: PropTypes.object, + impact: PropTypes.object, + scoresLoading: PropTypes.bool, + contactLoading: PropTypes.bool, + utilityLoading: PropTypes.bool, + simulationLoading: PropTypes.bool, + gatewayLoading: PropTypes.bool, + impactLoading: PropTypes.bool, + displayToggleColumns: PropTypes.bool, + toggleScores: PropTypes.bool, + toggleContacts: PropTypes.bool, + toggleAnalysis: PropTypes.bool, + toggleProjects: PropTypes.bool, + toggleImpact: PropTypes.bool, + onBuildingFilter: PropTypes.func, +}; -- GitLab From 65a59b732ce6c9ea9e23085e2eb2c5d63e5c6a73 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 1 Apr 2020 19:03:28 -0400 Subject: [PATCH 13/32] Remove not used pros --- src/containers/BGroup/BGroupBuildingTable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index 59e41395..0fa04552 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -13,7 +13,7 @@ import { } from 'reactstrap'; import userPropTypes from '../User/propTypes'; import completeProjectPropTypes from '../Project/propTypes'; -import buildingPropTypes from '../Building/propTypes'; +// import buildingPropTypes from '../Building/propTypes'; import AddressSearchBGroup from '../../components/AddressSearchBGroup'; /* eslint-disable no-param-reassign */ @@ -1078,7 +1078,7 @@ BGroupBuildingTable.propTypes = { edit: PropTypes.bool, bGroupId: PropTypes.string, user: userPropTypes, - buildings: buildingPropTypes, + // buildings: buildingPropTypes, projects: completeProjectPropTypes, searchBuildings: PropTypes.func, addBuildingToBGroup: PropTypes.func, -- GitLab From 10a40efc542e5c2f2dee355535c0e14b9174cfe2 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 2 Apr 2020 16:03:00 -0400 Subject: [PATCH 14/32] building added to the group by clickin on dropdpwn --- src/components/AddressSearchBGroup/index.js | 6 +++++- src/components/NavBar/index.js | 2 ++ src/containers/BGroup/BGroup.js | 10 ++++++++-- src/containers/BGroup/BGroupBuildingTable.js | 11 ++++++----- src/containers/SearchBar/actions.js | 1 + src/containers/SearchBar/reducer.js | 4 +++- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 605dda65..e648d6c0 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -85,12 +85,16 @@ class AddressSearchBGroup extends Component { ); } + console.log(this.props.buildings); + const content = (
{addressData} - {this.state.showAddButton && + {this.props.buildings !== undefined + && this.props.buildings.length === 0 + && this.state.showAddButton && + ); + } + } + const content = (
{addressData} - {this.props.buildings !== undefined - && this.props.buildings.length > 0 - && this.state.showAddButton && - - } + {result}
@@ -117,6 +130,7 @@ class AddressSearchBGroup extends Component { } AddressSearchBGroup.propTypes = { + buildingIds: PropTypes.arrayOf, buildings: PropTypes.objectOf, searchBuildings: PropTypes.func, buildingsSearched: PropTypes.func, diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index 601400d3..be111fc5 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -395,6 +395,7 @@ export class BGroup extends Component { } render() { + console.log(this.props.bGroup); // eslint-disable-line let content = ( ); diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index dab624fa..f74d69ea 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -876,6 +876,7 @@ export default class BGroupBuildingTable extends Component { Search and add address   building.building_id)} buildings={this.props.buildings} searchBuildings={this.handleSearchBuildings} addSelectedAddress={this.handleAddBuilding} diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index d74337fe..1e591417 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -31,7 +31,7 @@ function* getBuildingsByFilter(action) { bbl: 3012410005, bin: 3031524, borough: 'BROOKLYN', - building_id: 181794, + building_id: 181791, lot_id: 759242, street_address: '838 PARK PLACE', targeting_score: 73.9496248660236, -- GitLab From 70a2331e57361c64957e70a6b07de5159e88b9e2 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Mon, 6 Apr 2020 10:52:05 -0400 Subject: [PATCH 17/32] Update the questionnaire container --- src/containers/Questionnaire/index.js | 12 +++++------- src/containers/SearchBar/actions.js | 2 +- src/containers/SearchBar/reducer.js | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index 6a42eac1..112b37e8 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -129,15 +129,12 @@ class Questionnaire extends Component { const errorMessage = []; const validEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; //eslint-disable-line const validPhone = /^$|^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/; - + const requiredInformation = ['firstName', 'lastName', 'email', 'buildingSqFt', 'numberOfFloors']; + const requiredSurveyQuestions = [1, 2, 3, 15, 4, 7, 6, 8, 13, 5, 9]; Object.entries(data).forEach(formData => { - if (['buildingInfo', 'remoteSurvey', 'financialInitials'].includes(formData[0])) { Object.entries(formData[1]).forEach(fieldData => { - if (fieldData[0] !== 'other' && - fieldData[0] !== 'address' && - fieldData[0] !== 'buildingId' && - fieldData[0] !== 'phone' && + if (requiredInformation.includes(fieldData[0]) && fieldData[1].toString().replace(/^\s+|\s+$/g, '') === '') { emptyFields.push(this.nameMapping[fieldData[0]]); } @@ -157,7 +154,8 @@ class Questionnaire extends Component { if (typeof fieldData[1] === 'object' && fieldData[1].answer_id !== undefined && parseInt(fieldData[1].answer_id, 10) === -1 && - parseInt(fieldData[1].question_id, 10) !== 16) { + parseInt(fieldData[1].question_id, 10) !== 10 && + parseInt(fieldData[1].question_id, 10) in requiredSurveyQuestions) { emptyFields.push(this.nameMapping[fieldData[0]]); } }); diff --git a/src/containers/SearchBar/actions.js b/src/containers/SearchBar/actions.js index a41203b6..85e0052e 100644 --- a/src/containers/SearchBar/actions.js +++ b/src/containers/SearchBar/actions.js @@ -30,7 +30,7 @@ export function buildingsSearched(buildings, args) { ReactGA.event({ category: 'Search', action: 'Fail', label: `${address} not found` }); } } - console.log(buildings); + console.log(buildings); // eslint-disable-line return { type: SEARCH_BUILDINGS_SUCCESS, payload: buildings, diff --git a/src/containers/SearchBar/reducer.js b/src/containers/SearchBar/reducer.js index 12a6c0f0..53947368 100644 --- a/src/containers/SearchBar/reducer.js +++ b/src/containers/SearchBar/reducer.js @@ -19,7 +19,7 @@ export default function (state = initState, action) { error: false, }; case SEARCH_BUILDINGS_SUCCESS: { - console.log(action.payload); + console.log(action.payload); // eslint-disable-line return { ...state, buildings: action.payload, -- GitLab From 06473521ff8784b9494245fa4e1d165686547c2d Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Mon, 6 Apr 2020 11:50:18 -0400 Subject: [PATCH 18/32] Display the review page --- .../ReviewAnswers/BuildingInfo.js | 8 +- .../ReviewAnswers/FinancialInitial.js | 48 ++++----- .../ReviewAnswers/RemoteSurvey.js | 98 +++++++++---------- .../Questionnaire/ReviewAnswers/index.js | 12 +-- 4 files changed, 84 insertions(+), 82 deletions(-) diff --git a/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js b/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js index 1116565e..5f92d768 100644 --- a/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js +++ b/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js @@ -40,7 +40,8 @@ const BuildingInfo = (props) => { First Name
- {props.upperFirstLetter(props.data.firstName)} + {/* {props.upperFirstLetter(props.data.firstName)} */} + {props.data.firstName}
@@ -48,7 +49,8 @@ const BuildingInfo = (props) => { Last Name
- {props.upperFirstLetter(props.data.lastName)} + {/* {props.upperFirstLetter(props.data.lastName)} */} + {props.data.lastName}
@@ -164,7 +166,7 @@ BuildingInfo.propTypes = { tableHeader: PropTypes.objectOf, title: PropTypes.string, data: PropTypes.objectOf, - upperFirstLetter: PropTypes.func, + // upperFirstLetter: PropTypes.func, }; export default BuildingInfo; diff --git a/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js b/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js index 672c6a80..5e2d0061 100644 --- a/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js +++ b/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js @@ -30,9 +30,9 @@ const FinancialInitial = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.legalOwnership.answer_id] - ) + // props.upperFirstLetter( + // props.answers[props.data.legalOwnership.answer_id] + // ) }
@@ -44,9 +44,9 @@ const FinancialInitial = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.numberOfDobViolations.answer_id] - ) + // props.upperFirstLetter( + // props.answers[props.data.numberOfDobViolations.answer_id] + // ) }
@@ -58,9 +58,9 @@ const FinancialInitial = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.bankruptcyPast.answer_id] - ) + // props.upperFirstLetter( + // props.answers[props.data.bankruptcyPast.answer_id] + // ) }
@@ -72,9 +72,9 @@ const FinancialInitial = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.currentOnEnergyBills.answer_id] - ) + // props.upperFirstLetter( + // props.answers[props.data.currentOnEnergyBills.answer_id] + // ) }
@@ -86,9 +86,9 @@ const FinancialInitial = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.currentMortgageBalance.answer_id] - ) + // props.upperFirstLetter( + // props.answers[props.data.currentMortgageBalance.answer_id] + // ) }
@@ -100,9 +100,9 @@ const FinancialInitial = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.profitable.answer_id] - ) + // props.upperFirstLetter( + // props.answers[props.data.profitable.answer_id] + // ) }
@@ -114,9 +114,9 @@ const FinancialInitial = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.budgetForDownPayment.answer_id] - ) + // props.upperFirstLetter( + // props.answers[props.data.budgetForDownPayment.answer_id] + // ) }
@@ -130,9 +130,9 @@ const FinancialInitial = (props) => { FinancialInitial.propTypes = { tableHeader: PropTypes.objectOf, title: PropTypes.string, - data: PropTypes.objectOf, - upperFirstLetter: PropTypes.func, - answers: PropTypes.objectOf, + // data: PropTypes.objectOf, + // upperFirstLetter: PropTypes.func, + // answers: PropTypes.objectOf, }; export default FinancialInitial; diff --git a/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js b/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js index df4aec6d..4d389d65 100644 --- a/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js +++ b/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js @@ -29,9 +29,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.heatingSystem.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.heatingSystem.answer_id] + // ) }
@@ -41,9 +41,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.heatingFuelSource.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.heatingFuelSource.answer_id] + // ) }
@@ -55,9 +55,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.DHWSameBoiler.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.DHWSameBoiler.answer_id] + // ) }
@@ -69,9 +69,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.ageOfHeatGenerateSystem.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.ageOfHeatGenerateSystem.answer_id] + // ) }
@@ -83,9 +83,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.planToReplaceHS.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.planToReplaceHS.answer_id] + // ) }
@@ -97,9 +97,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.hallwaysHeated.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.hallwaysHeated.answer_id] + // ) }
@@ -109,9 +109,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.basementHeated.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.basementHeated.answer_id] + // ) }
@@ -123,9 +123,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.stairwellsHeated.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.stairwellsHeated.answer_id] + // ) }
@@ -135,9 +135,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.floorsHeated.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.floorsHeated.answer_id] + // ) }
@@ -149,9 +149,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.accessibleByStairwell.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.accessibleByStairwell.answer_id] + // ) }
@@ -163,9 +163,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.backFacadeAttached.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.backFacadeAttached.answer_id] + // ) }
@@ -178,9 +178,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.exteriorWallsAttached.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.exteriorWallsAttached.answer_id] + // ) }
@@ -192,9 +192,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.tenantComplaintsComfort.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.tenantComplaintsComfort.answer_id] + // ) }
@@ -206,9 +206,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.tenantComplaintsWindows.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.tenantComplaintsWindows.answer_id] + // ) }
@@ -220,9 +220,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.meteredForElectricity.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.meteredForElectricity.answer_id] + // ) }
@@ -234,9 +234,9 @@ const RemoteSurvey = (props) => {
{ - props.upperFirstLetter( - props.answers[props.data.numberOfHeatingViolations.answer_id] - ) + // props.upperFirstLetter( + props.answers[props.data.numberOfHeatingViolations.answer_id] + // ) }
@@ -251,7 +251,7 @@ RemoteSurvey.propTypes = { tableHeader: PropTypes.objectOf, title: PropTypes.string, data: PropTypes.objectOf, - upperFirstLetter: PropTypes.func, + // upperFirstLetter: PropTypes.func, answers: PropTypes.objectOf, }; diff --git a/src/components/Questionnaire/ReviewAnswers/index.js b/src/components/Questionnaire/ReviewAnswers/index.js index b83b0223..c5e46950 100644 --- a/src/components/Questionnaire/ReviewAnswers/index.js +++ b/src/components/Questionnaire/ReviewAnswers/index.js @@ -7,9 +7,9 @@ import FinancialInitial from './FinancialInitial'; const ReviewAnswers = (props) => { - const upperFirstLetter = (str) => { - return str.charAt(0).toUpperCase() + str.slice(1); - }; + // const upperFirstLetter = (str) => { + // return str.charAt(0).toUpperCase() + str.slice(1); + // }; return (
@@ -19,7 +19,7 @@ const ReviewAnswers = (props) => { tableHeader={props.tableHeader} title={'Building Info'} data={props.buildingInfo} - upperFirstLetter={upperFirstLetter} + // upperFirstLetter={upperFirstLetter} /> @@ -28,7 +28,7 @@ const ReviewAnswers = (props) => { title={'Remote Survey'} data={props.remoteSurvey} answers={props.answers} - upperFirstLetter={upperFirstLetter} + // upperFirstLetter={upperFirstLetter} /> @@ -37,7 +37,7 @@ const ReviewAnswers = (props) => { title={'Financial Initial Go/NoGo'} data={props.financialInitials} answers={props.answers} - upperFirstLetter={upperFirstLetter} + // upperFirstLetter={upperFirstLetter} /> -- GitLab From 934aad9b144d431bca07f74e3a65a0f61426c0f3 Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Mon, 6 Apr 2020 12:08:44 -0400 Subject: [PATCH 19/32] success message after adding building --- src/components/AddressSearchBGroup/index.js | 10 ++++++++++ src/containers/SearchBar/sagas.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 41f786ba..858de432 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -21,6 +21,7 @@ class AddressSearchBGroup extends Component { addressFound: false, address: '', showResult: false, + showSuccessMessage: false, }; } @@ -47,6 +48,7 @@ class AddressSearchBGroup extends Component { handleOnAddBuilding = () => { this.props.addSelectedAddress(); + this.setState({ showSuccessMessage: true }); } handleOnChange = (event) => { @@ -96,6 +98,7 @@ class AddressSearchBGroup extends Component {
); } else { + console.log(this.state.showSuccessMessage); result = ( ); + if (this.state.showSuccessMessage) { + result = ( +
+ Success! +
+ ); + } } } diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 1e591417..8d332814 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -31,7 +31,7 @@ function* getBuildingsByFilter(action) { bbl: 3012410005, bin: 3031524, borough: 'BROOKLYN', - building_id: 181791, + building_id: 181798, lot_id: 759242, street_address: '838 PARK PLACE', targeting_score: 73.9496248660236, -- GitLab From c5730a46248e7596aa72e8c8dc078bc98047e4fb Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 6 Apr 2020 12:14:44 -0400 Subject: [PATCH 20/32] updates --- src/components/AddressSearchBGroup/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 41f786ba..12039246 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -25,11 +25,9 @@ class AddressSearchBGroup extends Component { } componentWillReceiveProps(nextProps) { - if ( - this.props.buildings !== nextProps.buildings - ) { + if (this.props.buildings !== nextProps.buildings) { this.setState({ - address: nextProps.buildings.address, + address: nextProps.buildings[0].placeName, }); } } -- GitLab From 6c2f2d7cbd31bd30fdd6725d35ae915f9129d967 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 6 Apr 2020 13:26:48 -0400 Subject: [PATCH 21/32] Fix style, update sagas --- src/components/AddressSearchBGroup/index.js | 58 ++++++++++--------- src/components/AddressSearchBGroup/styles.css | 6 ++ src/containers/BGroup/BGroupBuildingTable.js | 2 +- src/containers/SearchBar/sagas.js | 2 +- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index d7895966..327dc5a6 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -20,14 +20,16 @@ class AddressSearchBGroup extends Component { viewport: {}, addressFound: false, address: '', - showResult: false, - showSuccessMessage: false, + searchClicked: false, + addClicked: false, + bGroupBuildings: this.props.bGroupBuildings, }; } componentWillReceiveProps(nextProps) { if (this.props.buildings !== nextProps.buildings) { this.setState({ + bGroupBuildings: this.props.bGroupBuildings, address: nextProps.buildings[0].placeName, }); } @@ -38,7 +40,7 @@ class AddressSearchBGroup extends Component { viewport, address: item.place_name, addressFound: true, - showResult: true, + searchClicked: true, }, () => { this.props.searchBuildings(this.state.address); }); @@ -46,14 +48,15 @@ class AddressSearchBGroup extends Component { handleOnAddBuilding = () => { this.props.addSelectedAddress(); - this.setState({ showSuccessMessage: true }); + this.setState({ addClicked: true }); } handleOnChange = (event) => { this.setState({ address: event.target.value, addressFound: false, - showResult: false, + searchClicked: false, + addClicked: false, }); } @@ -86,32 +89,33 @@ class AddressSearchBGroup extends Component { } let result = ''; - if (this.props.buildings !== undefined - && this.props.buildings.length > 0 - && this.state.showResult) { - if (this.props.buildingIds.includes(this.props.buildings[0].building_id)) { - result = ( -
- This address already exists in the building group, please enter another one. -
- ); - } else { - console.log(this.state.showSuccessMessage); - result = ( - - ); - if (this.state.showSuccessMessage) { + const bGroupBuildingIDs = this.state.bGroupBuildings.map(building => building.building_id); + if (this.props.buildings !== undefined && this.props.buildings.length > 0) { + if (this.state.searchClicked) { + if (bGroupBuildingIDs.includes(this.props.buildings[0].building_id)) { result = ( -
- Success! +
+ This address already exists in the building group, please enter another one.
); + } else { + result = ( + + ); } } + if (this.state.addClicked && + !bGroupBuildingIDs.includes(this.props.buildings[0].building_id)) { + result = ( +
+ Building has been successfully added to the group! +
+ ); + } } const content = ( @@ -138,7 +142,7 @@ class AddressSearchBGroup extends Component { } AddressSearchBGroup.propTypes = { - buildingIds: PropTypes.arrayOf, + bGroupBuildings: PropTypes.arrayOf, buildings: PropTypes.objectOf, searchBuildings: PropTypes.func, buildingsSearched: PropTypes.func, diff --git a/src/components/AddressSearchBGroup/styles.css b/src/components/AddressSearchBGroup/styles.css index ae86686a..b33e3e8e 100644 --- a/src/components/AddressSearchBGroup/styles.css +++ b/src/components/AddressSearchBGroup/styles.css @@ -95,6 +95,12 @@ li.navbar-input>form { background: #EEEEEE; } +.resultMessage { + color: #B92828; + font-size: 0.8em; + font-weight: bold; +} + @media screen and (max-width: 992px) { .addressSearchInputBGroup { width: 600px !important; diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index f74d69ea..c7bafb7f 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -876,7 +876,7 @@ export default class BGroupBuildingTable extends Component { Search and add address   building.building_id)} + bGroupBuildings={this.props.bGroup.bGroupBuildings} buildings={this.props.buildings} searchBuildings={this.handleSearchBuildings} addSelectedAddress={this.handleAddBuilding} diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 8d332814..8b655e21 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -31,7 +31,7 @@ function* getBuildingsByFilter(action) { bbl: 3012410005, bin: 3031524, borough: 'BROOKLYN', - building_id: 181798, + building_id: 181724, lot_id: 759242, street_address: '838 PARK PLACE', targeting_score: 73.9496248660236, -- GitLab From 8ab5dc40f68fb5d81a1c9f9fa12157f492e5996c Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 6 Apr 2020 14:12:11 -0400 Subject: [PATCH 22/32] update styles --- src/components/AddressSearchBGroup/index.js | 4 ++-- src/components/AddressSearchBGroup/styles.css | 8 +++++++- src/containers/SearchBar/sagas.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 327dc5a6..71fd8df6 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -94,7 +94,7 @@ class AddressSearchBGroup extends Component { if (this.state.searchClicked) { if (bGroupBuildingIDs.includes(this.props.buildings[0].building_id)) { result = ( -
+
This address already exists in the building group, please enter another one.
); @@ -111,7 +111,7 @@ class AddressSearchBGroup extends Component { if (this.state.addClicked && !bGroupBuildingIDs.includes(this.props.buildings[0].building_id)) { result = ( -
+
Building has been successfully added to the group!
); diff --git a/src/components/AddressSearchBGroup/styles.css b/src/components/AddressSearchBGroup/styles.css index b33e3e8e..b8263245 100644 --- a/src/components/AddressSearchBGroup/styles.css +++ b/src/components/AddressSearchBGroup/styles.css @@ -95,7 +95,13 @@ li.navbar-input>form { background: #EEEEEE; } -.resultMessage { +.successMessage { + color: #336633; + font-size: 0.8em; + font-weight: bold; +} + +.errorMessage { color: #B92828; font-size: 0.8em; font-weight: bold; diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 8b655e21..bd814cd3 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -31,7 +31,7 @@ function* getBuildingsByFilter(action) { bbl: 3012410005, bin: 3031524, borough: 'BROOKLYN', - building_id: 181724, + building_id: 181725, lot_id: 759242, street_address: '838 PARK PLACE', targeting_score: 73.9496248660236, -- GitLab From 4fb67d176888c18554a2bf841c4f18d05162bcc2 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Mon, 6 Apr 2020 14:26:25 -0400 Subject: [PATCH 23/32] Update ReviewAnswers component --- .../ReviewAnswers/BuildingInfo.js | 3 - .../ReviewAnswers/FinancialInitial.js | 47 +++++---- .../ReviewAnswers/RemoteSurvey.js | 97 ++++++------------- .../Questionnaire/ReviewAnswers/index.js | 7 -- 4 files changed, 53 insertions(+), 101 deletions(-) diff --git a/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js b/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js index 5f92d768..499c385d 100644 --- a/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js +++ b/src/components/Questionnaire/ReviewAnswers/BuildingInfo.js @@ -40,7 +40,6 @@ const BuildingInfo = (props) => { First Name
- {/* {props.upperFirstLetter(props.data.firstName)} */} {props.data.firstName}
@@ -49,7 +48,6 @@ const BuildingInfo = (props) => { Last Name
- {/* {props.upperFirstLetter(props.data.lastName)} */} {props.data.lastName}
@@ -166,7 +164,6 @@ BuildingInfo.propTypes = { tableHeader: PropTypes.objectOf, title: PropTypes.string, data: PropTypes.objectOf, - // upperFirstLetter: PropTypes.func, }; export default BuildingInfo; diff --git a/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js b/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js index 5e2d0061..3d384cc3 100644 --- a/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js +++ b/src/components/Questionnaire/ReviewAnswers/FinancialInitial.js @@ -30,9 +30,9 @@ const FinancialInitial = (props) => {
{ - // props.upperFirstLetter( - // props.answers[props.data.legalOwnership.answer_id] - // ) + props.data.legalOwnership.answer_id === -1 ? + '--' : + props.answers[props.data.legalOwnership.answer_id] }
@@ -44,9 +44,9 @@ const FinancialInitial = (props) => {
{ - // props.upperFirstLetter( - // props.answers[props.data.numberOfDobViolations.answer_id] - // ) + props.data.numberOfDobViolations.answer_id === -1 ? + '--' : + props.answers[props.data.numberOfDobViolations.answer_id] }
@@ -58,9 +58,9 @@ const FinancialInitial = (props) => {
{ - // props.upperFirstLetter( - // props.answers[props.data.bankruptcyPast.answer_id] - // ) + props.data.bankruptcyPast.answer_id === -1 ? + '--' : + props.answers[props.data.bankruptcyPast.answer_id] }
@@ -72,9 +72,9 @@ const FinancialInitial = (props) => {
{ - // props.upperFirstLetter( - // props.answers[props.data.currentOnEnergyBills.answer_id] - // ) + props.data.currentOnEnergyBills.answer_id === -1 ? + '--' : + props.answers[props.data.currentOnEnergyBills.answer_id] }
@@ -86,9 +86,9 @@ const FinancialInitial = (props) => {
{ - // props.upperFirstLetter( - // props.answers[props.data.currentMortgageBalance.answer_id] - // ) + props.data.currentMortgageBalance.answer_id === -1 ? + '--' : + props.answers[props.data.currentMortgageBalance.answer_id] }
@@ -100,9 +100,9 @@ const FinancialInitial = (props) => {
{ - // props.upperFirstLetter( - // props.answers[props.data.profitable.answer_id] - // ) + props.data.profitable.answer_id === -1 ? + '--' : + props.answers[props.data.profitable.answer_id] }
@@ -114,9 +114,9 @@ const FinancialInitial = (props) => {
{ - // props.upperFirstLetter( - // props.answers[props.data.budgetForDownPayment.answer_id] - // ) + props.data.budgetForDownPayment.answer_id === -1 ? + '--' : + props.answers[props.data.budgetForDownPayment.answer_id] }
@@ -130,9 +130,8 @@ const FinancialInitial = (props) => { FinancialInitial.propTypes = { tableHeader: PropTypes.objectOf, title: PropTypes.string, - // data: PropTypes.objectOf, - // upperFirstLetter: PropTypes.func, - // answers: PropTypes.objectOf, + data: PropTypes.objectOf, + answers: PropTypes.objectOf, }; export default FinancialInitial; diff --git a/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js b/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js index 4d389d65..a85e8508 100644 --- a/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js +++ b/src/components/Questionnaire/ReviewAnswers/RemoteSurvey.js @@ -28,11 +28,7 @@ const RemoteSurvey = (props) => { Heating System
- { - // props.upperFirstLetter( - props.answers[props.data.heatingSystem.answer_id] - // ) - } + { props.answers[props.data.heatingSystem.answer_id] }
@@ -40,11 +36,7 @@ const RemoteSurvey = (props) => { Heating Fuel Source
- { - // props.upperFirstLetter( - props.answers[props.data.heatingFuelSource.answer_id] - // ) - } + { props.answers[props.data.heatingFuelSource.answer_id] }
@@ -54,11 +46,7 @@ const RemoteSurvey = (props) => { Is Domestic Hot Water (DHW) and heat prepared by the same boiler?
- { - // props.upperFirstLetter( - props.answers[props.data.DHWSameBoiler.answer_id] - // ) - } + { props.answers[props.data.DHWSameBoiler.answer_id] }
@@ -68,11 +56,7 @@ const RemoteSurvey = (props) => { Age of heat generating system?
- { - // props.upperFirstLetter( - props.answers[props.data.ageOfHeatGenerateSystem.answer_id] - // ) - } + { props.answers[props.data.ageOfHeatGenerateSystem.answer_id] }
@@ -82,11 +66,7 @@ const RemoteSurvey = (props) => { When do you plan to replace the heating system?
- { - // props.upperFirstLetter( - props.answers[props.data.planToReplaceHS.answer_id] - // ) - } + { props.answers[props.data.planToReplaceHS.answer_id] }
@@ -96,11 +76,7 @@ const RemoteSurvey = (props) => { Hallways heated?
- { - // props.upperFirstLetter( - props.answers[props.data.hallwaysHeated.answer_id] - // ) - } + { props.answers[props.data.hallwaysHeated.answer_id] }
@@ -108,11 +84,7 @@ const RemoteSurvey = (props) => { Basement heated?
- { - // props.upperFirstLetter( - props.answers[props.data.basementHeated.answer_id] - // ) - } + { props.answers[props.data.basementHeated.answer_id] }
@@ -122,11 +94,7 @@ const RemoteSurvey = (props) => { Stairwells heated?
- { - // props.upperFirstLetter( - props.answers[props.data.stairwellsHeated.answer_id] - // ) - } + { props.answers[props.data.stairwellsHeated.answer_id] }
@@ -134,11 +102,7 @@ const RemoteSurvey = (props) => { Floors heated?
- { - // props.upperFirstLetter( - props.answers[props.data.floorsHeated.answer_id] - // ) - } + { props.answers[props.data.floorsHeated.answer_id] }
@@ -149,9 +113,9 @@ const RemoteSurvey = (props) => {
{ - // props.upperFirstLetter( - props.answers[props.data.accessibleByStairwell.answer_id] - // ) + props.data.accessibleByStairwell.answer_id === -1 ? + '--' : + props.answers[props.data.accessibleByStairwell.answer_id] }
@@ -163,9 +127,9 @@ const RemoteSurvey = (props) => {
{ - // props.upperFirstLetter( - props.answers[props.data.backFacadeAttached.answer_id] - // ) + props.data.backFacadeAttached.answer_id === -1 ? + '--' : + props.answers[props.data.backFacadeAttached.answer_id] }
@@ -178,9 +142,9 @@ const RemoteSurvey = (props) => {
{ - // props.upperFirstLetter( - props.answers[props.data.exteriorWallsAttached.answer_id] - // ) + props.data.exteriorWallsAttached.answer_id === -1 ? + '--' : + props.answers[props.data.exteriorWallsAttached.answer_id] }
@@ -192,9 +156,9 @@ const RemoteSurvey = (props) => {
{ - // props.upperFirstLetter( - props.answers[props.data.tenantComplaintsComfort.answer_id] - // ) + props.data.tenantComplaintsComfort.answer_id === -1 ? + '--' : + props.answers[props.data.tenantComplaintsComfort.answer_id] }
@@ -206,9 +170,9 @@ const RemoteSurvey = (props) => {
{ - // props.upperFirstLetter( - props.answers[props.data.tenantComplaintsWindows.answer_id] - // ) + props.data.tenantComplaintsWindows.answer_id === -1 ? + '--' : + props.answers[props.data.tenantComplaintsWindows.answer_id] }
@@ -220,9 +184,9 @@ const RemoteSurvey = (props) => {
{ - // props.upperFirstLetter( - props.answers[props.data.meteredForElectricity.answer_id] - // ) + props.data.meteredForElectricity.answer_id === -1 ? + '--' : + props.answers[props.data.meteredForElectricity.answer_id] }
@@ -234,9 +198,9 @@ const RemoteSurvey = (props) => {
{ - // props.upperFirstLetter( - props.answers[props.data.numberOfHeatingViolations.answer_id] - // ) + props.data.numberOfHeatingViolations.answer_id === -1 ? + '--' : + props.answers[props.data.numberOfHeatingViolations.answer_id] }
@@ -251,7 +215,6 @@ RemoteSurvey.propTypes = { tableHeader: PropTypes.objectOf, title: PropTypes.string, data: PropTypes.objectOf, - // upperFirstLetter: PropTypes.func, answers: PropTypes.objectOf, }; diff --git a/src/components/Questionnaire/ReviewAnswers/index.js b/src/components/Questionnaire/ReviewAnswers/index.js index c5e46950..3f22dae1 100644 --- a/src/components/Questionnaire/ReviewAnswers/index.js +++ b/src/components/Questionnaire/ReviewAnswers/index.js @@ -7,10 +7,6 @@ import FinancialInitial from './FinancialInitial'; const ReviewAnswers = (props) => { - // const upperFirstLetter = (str) => { - // return str.charAt(0).toUpperCase() + str.slice(1); - // }; - return (
@@ -19,7 +15,6 @@ const ReviewAnswers = (props) => { tableHeader={props.tableHeader} title={'Building Info'} data={props.buildingInfo} - // upperFirstLetter={upperFirstLetter} /> @@ -28,7 +23,6 @@ const ReviewAnswers = (props) => { title={'Remote Survey'} data={props.remoteSurvey} answers={props.answers} - // upperFirstLetter={upperFirstLetter} /> @@ -37,7 +31,6 @@ const ReviewAnswers = (props) => { title={'Financial Initial Go/NoGo'} data={props.financialInitials} answers={props.answers} - // upperFirstLetter={upperFirstLetter} /> -- GitLab From c07f6d26e03a002be0bd1d8f96292fb99e9cfd99 Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Mon, 6 Apr 2020 14:33:21 -0400 Subject: [PATCH 24/32] in progress - building numbers --- src/components/AddressSearchBGroup/index.js | 3 +++ src/containers/BGroup/BGroupBuildingTable.js | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 71fd8df6..7e13cde1 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -23,6 +23,7 @@ class AddressSearchBGroup extends Component { searchClicked: false, addClicked: false, bGroupBuildings: this.props.bGroupBuildings, + increaseRow: false, }; } @@ -115,6 +116,7 @@ class AddressSearchBGroup extends Component { Building has been successfully added to the group!
); + this.setState({ increaseRow: true }); } } @@ -147,6 +149,7 @@ AddressSearchBGroup.propTypes = { searchBuildings: PropTypes.func, buildingsSearched: PropTypes.func, addSelectedAddress: PropTypes.func, + increaseRow: PropTypes.bool, }; diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index c7bafb7f..cbc5b973 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -880,12 +880,16 @@ export default class BGroupBuildingTable extends Component { buildings={this.props.buildings} searchBuildings={this.handleSearchBuildings} addSelectedAddress={this.handleAddBuilding} + increaseRow={this.props.increaseRow} />
= 0 ? '' : 'none' }}>
-
{this.state.numRows} buildings
+ {console.log(this.props.increaseRow)} + {console.log(this.state.numRows)} + {/*
{this.props.increaseRow ? this.state.numRows+1 : this.state.numRows} buildings
*/} + {/*
{this.state.numRows} buildings
*/}
Date: Mon, 6 Apr 2020 16:13:00 -0400 Subject: [PATCH 25/32] Add error handing case --- src/components/AddressSearchBGroup/index.js | 9 ++++ src/containers/SearchBar/sagas.js | 50 ++++++++++----------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 71fd8df6..a02d64cc 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -89,6 +89,7 @@ class AddressSearchBGroup extends Component { } let result = ''; + console.log(this.props.buildings); const bGroupBuildingIDs = this.state.bGroupBuildings.map(building => building.building_id); if (this.props.buildings !== undefined && this.props.buildings.length > 0) { if (this.state.searchClicked) { @@ -118,6 +119,14 @@ class AddressSearchBGroup extends Component { } } + if (this.state.searchClicked && + (this.props.buildings === undefined || this.props.buildings.length === 0)) { + result = ( +
+ There is an error in building address search, please contact admin. +
+ ); + } const content = (
diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index bd814cd3..d4c3335a 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -1,6 +1,6 @@ -import { put, takeLatest } from 'redux-saga/effects'; -// import request from '../../utils/request'; -// import { getHeaders, buildingsURL } from '../../utils/restServices'; +import { call, put, takeLatest } from 'redux-saga/effects'; +import request from '../../utils/request'; +import { getHeaders, buildingsURL } from '../../utils/restServices'; import { SEARCH_BUILDINGS, @@ -16,30 +16,30 @@ import { */ function* getBuildingsByFilter(action) { const placeName = action.address; - // const res = yield call( - // request, - // `${buildingsURL}?$place_name=${placeName}limit=300`, { - // method: 'GET', - // headers: getHeaders(), - // } - // ); + const res = yield call( + request, + `${buildingsURL}?place_name=${placeName}&limit=300`, { + method: 'GET', + headers: getHeaders(), + } + ); // For now, we commented out http call and hard coded the response data - const res = { - data: [ - { - bbl: 3012410005, - bin: 3031524, - borough: 'BROOKLYN', - building_id: 181725, - lot_id: 759242, - street_address: '838 PARK PLACE', - targeting_score: 73.9496248660236, - zipcode: '11216', - placeName, - }, - ], - }; + // const res = { + // data: [ + // { + // bbl: 3012410005, + // bin: 3031524, + // borough: 'BROOKLYN', + // building_id: 181725, + // lot_id: 759242, + // street_address: '838 PARK PLACE', + // targeting_score: 73.9496248660236, + // zipcode: '11216', + // placeName, + // }, + // ], + // }; if (!res.err) { yield put(buildingsSearched(res.data, placeName)); -- GitLab From e33fd30f6169d6e35fbc5d0ec3e18d1d5789d0dc Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Mon, 6 Apr 2020 16:23:59 -0400 Subject: [PATCH 26/32] num increased when added a building --- src/components/AddressSearchBGroup/index.js | 4 ---- src/containers/BGroup/BGroupBuildingTable.js | 24 +++++++++++++++----- src/containers/SearchBar/sagas.js | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 7e13cde1..1b3fce96 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -23,7 +23,6 @@ class AddressSearchBGroup extends Component { searchClicked: false, addClicked: false, bGroupBuildings: this.props.bGroupBuildings, - increaseRow: false, }; } @@ -116,7 +115,6 @@ class AddressSearchBGroup extends Component { Building has been successfully added to the group!
); - this.setState({ increaseRow: true }); } } @@ -149,8 +147,6 @@ AddressSearchBGroup.propTypes = { searchBuildings: PropTypes.func, buildingsSearched: PropTypes.func, addSelectedAddress: PropTypes.func, - increaseRow: PropTypes.bool, }; - export default AddressSearchBGroup; diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index cbc5b973..f6e1f820 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -32,6 +32,7 @@ export default class BGroupBuildingTable extends Component { recommendedRetrofitsToggle: {}, recommendedDeemedToggle: {}, completedDeemedToggle: {}, + increaseNum: false, }; componentWillUnmount() { @@ -49,6 +50,7 @@ export default class BGroupBuildingTable extends Component { { building_ids: [item.building_id] }, item.placeName, ); + this.setState({ increaseNum: true }); } handleDeleteBuilding = (buildingId) => { @@ -865,6 +867,21 @@ export default class BGroupBuildingTable extends Component { lineHeight: 1.15, }; + let rowNum = this.state.numRows; + if (this.state.increaseNum === true) { + rowNum = ( +
+
{this.state.numRows + 1} buildings
+
+ ); + } else if (this.state.increaseNum === false) { + rowNum = ( +
+
{this.state.numRows} buildings
+
+ ); + } + return (
@@ -880,16 +897,12 @@ export default class BGroupBuildingTable extends Component { buildings={this.props.buildings} searchBuildings={this.handleSearchBuildings} addSelectedAddress={this.handleAddBuilding} - increaseRow={this.props.increaseRow} />
= 0 ? '' : 'none' }}>
- {console.log(this.props.increaseRow)} - {console.log(this.state.numRows)} - {/*
{this.props.increaseRow ? this.state.numRows+1 : this.state.numRows} buildings
*/} - {/*
{this.state.numRows} buildings
*/} + {rowNum}
Date: Mon, 6 Apr 2020 16:34:15 -0400 Subject: [PATCH 27/32] use real endpoints --- src/containers/SearchBar/sagas.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index e73de71d..9e46bf9a 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -26,21 +26,21 @@ function* getBuildingsByFilter(action) { // For now, we commented out http call and hard coded the response data - const res = { - data: [ - { - bbl: 3012410005, - bin: 3031524, - borough: 'BROOKLYN', - building_id: 181725, - lot_id: 759242, - street_address: '838 PARK PLACE', - targeting_score: 73.9496248660236, - zipcode: '11216', - placeName, - }, - ], - }; + // const res = { + // data: [ + // { + // bbl: 3012410005, + // bin: 3031524, + // borough: 'BROOKLYN', + // building_id: 181725, + // lot_id: 759242, + // street_address: '838 PARK PLACE', + // targeting_score: 73.9496248660236, + // zipcode: '11216', + // placeName, + // }, + // ], + // }; if (!res.err) { yield put(buildingsSearched(res.data, placeName)); -- GitLab From 3f1ddfab9d5742567c06079a90450745bd4ef31c Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 6 Apr 2020 17:16:50 -0400 Subject: [PATCH 28/32] Fix empty building return handling --- src/components/AddressSearchBGroup/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AddressSearchBGroup/index.js b/src/components/AddressSearchBGroup/index.js index 5cd16731..ca18c291 100644 --- a/src/components/AddressSearchBGroup/index.js +++ b/src/components/AddressSearchBGroup/index.js @@ -27,7 +27,7 @@ class AddressSearchBGroup extends Component { } componentWillReceiveProps(nextProps) { - if (this.props.buildings !== nextProps.buildings) { + if (this.props.buildings !== nextProps.buildings && nextProps.buildings.length > 0) { this.setState({ bGroupBuildings: this.props.bGroupBuildings, address: nextProps.buildings[0].placeName, -- GitLab From 39dd580c98808dc63302bdb9be66b691284d2d33 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 6 Apr 2020 17:20:13 -0400 Subject: [PATCH 29/32] Remove comments --- src/containers/SearchBar/sagas.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 9e46bf9a..47288ccd 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -24,24 +24,6 @@ function* getBuildingsByFilter(action) { } ); - // For now, we commented out http call and hard coded the response data - - // const res = { - // data: [ - // { - // bbl: 3012410005, - // bin: 3031524, - // borough: 'BROOKLYN', - // building_id: 181725, - // lot_id: 759242, - // street_address: '838 PARK PLACE', - // targeting_score: 73.9496248660236, - // zipcode: '11216', - // placeName, - // }, - // ], - // }; - if (!res.err) { yield put(buildingsSearched(res.data, placeName)); } else { -- GitLab From dd57c6597fad1f73948cc71161b011add3222a0f Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 7 Apr 2020 12:01:12 -0400 Subject: [PATCH 30/32] Remove console logs --- src/containers/BGroup/BGroup.js | 1 - src/containers/SearchBar/actions.js | 1 - src/containers/SearchBar/reducer.js | 1 - 3 files changed, 3 deletions(-) diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index be111fc5..601400d3 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -395,7 +395,6 @@ export class BGroup extends Component { } render() { - console.log(this.props.bGroup); // eslint-disable-line let content = ( ); diff --git a/src/containers/SearchBar/actions.js b/src/containers/SearchBar/actions.js index 85e0052e..623714c8 100644 --- a/src/containers/SearchBar/actions.js +++ b/src/containers/SearchBar/actions.js @@ -30,7 +30,6 @@ export function buildingsSearched(buildings, args) { ReactGA.event({ category: 'Search', action: 'Fail', label: `${address} not found` }); } } - console.log(buildings); // eslint-disable-line return { type: SEARCH_BUILDINGS_SUCCESS, payload: buildings, diff --git a/src/containers/SearchBar/reducer.js b/src/containers/SearchBar/reducer.js index 53947368..fbef0b65 100644 --- a/src/containers/SearchBar/reducer.js +++ b/src/containers/SearchBar/reducer.js @@ -19,7 +19,6 @@ export default function (state = initState, action) { error: false, }; case SEARCH_BUILDINGS_SUCCESS: { - console.log(action.payload); // eslint-disable-line return { ...state, buildings: action.payload, -- GitLab From 91851cc4725a2ddb0a3f9f761f4e21baad92e638 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Tue, 7 Apr 2020 13:06:33 -0400 Subject: [PATCH 31/32] Update the validation condition --- src/containers/Questionnaire/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/containers/Questionnaire/index.js b/src/containers/Questionnaire/index.js index 112b37e8..fa33a282 100644 --- a/src/containers/Questionnaire/index.js +++ b/src/containers/Questionnaire/index.js @@ -130,7 +130,7 @@ class Questionnaire extends Component { const validEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; //eslint-disable-line const validPhone = /^$|^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/; const requiredInformation = ['firstName', 'lastName', 'email', 'buildingSqFt', 'numberOfFloors']; - const requiredSurveyQuestions = [1, 2, 3, 15, 4, 7, 6, 8, 13, 5, 9]; + const requiredSurveyQuestions = [1, 2, 3, 15, 4, 7, 6, 8, 13, 14, 5, 9]; Object.entries(data).forEach(formData => { if (['buildingInfo', 'remoteSurvey', 'financialInitials'].includes(formData[0])) { Object.entries(formData[1]).forEach(fieldData => { @@ -155,7 +155,7 @@ class Questionnaire extends Component { fieldData[1].answer_id !== undefined && parseInt(fieldData[1].answer_id, 10) === -1 && parseInt(fieldData[1].question_id, 10) !== 10 && - parseInt(fieldData[1].question_id, 10) in requiredSurveyQuestions) { + requiredSurveyQuestions.includes(fieldData[1].question_id)) { emptyFields.push(this.nameMapping[fieldData[0]]); } }); -- GitLab From e73ac74a1ac4099727d98f4c442727092befcfd9 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 7 Apr 2020 18:15:36 -0400 Subject: [PATCH 32/32] Delete not used file, remove console log --- src/components/BuildingListTable/index.js | 2 - .../BGroup/BGroupBuildingTable.js.bak | 1110 ----------------- 2 files changed, 1112 deletions(-) delete mode 100644 src/containers/BGroup/BGroupBuildingTable.js.bak diff --git a/src/components/BuildingListTable/index.js b/src/components/BuildingListTable/index.js index 9abf1e1b..71366629 100644 --- a/src/components/BuildingListTable/index.js +++ b/src/components/BuildingListTable/index.js @@ -110,8 +110,6 @@ export default function BuildingListTable({ return acc; }, {}); - console.log(buildings); // eslint-disable-line - const buildingItems = buildings.map((building) => { let bblTd = (); if (building.bbl in lotGrouping || !bblDisplay) { diff --git a/src/containers/BGroup/BGroupBuildingTable.js.bak b/src/containers/BGroup/BGroupBuildingTable.js.bak deleted file mode 100644 index 5f7d41d4..00000000 --- a/src/containers/BGroup/BGroupBuildingTable.js.bak +++ /dev/null @@ -1,1110 +0,0 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import ReactTable from 'react-table'; -import ReactTooltip from 'react-tooltip'; -import { Link } from 'react-router'; -import { Icon } from 'react-fa'; -import ReactGA from 'react-ga'; -import { CSVLink } from 'react-csv'; -import { - Input, Collapse, UncontrolledDropdown, - DropdownToggle, DropdownMenu, DropdownItem, - UncontrolledTooltip, -} from 'reactstrap'; -import userPropTypes from '../User/propTypes'; -import completeProjectPropTypes from '../Project/propTypes'; -import buildingPropTypes from '../Building/propTypes'; -import SearchBar from '../../components/AddressSearchBGroup'; - -/* eslint-disable no-param-reassign */ -export default class BGroupBuildingTable extends Component { - state = { - edit: false, - // This relies on the fact that bgroup has already loaded - // when this component is allowed to mount - numRows: this.props.bGroup.bGroupBuildings.length, - totalRows: this.props.bGroup.bGroupBuildings, - displayScores: this.props.toggleScores, - displayContact: this.props.toggleContacts, - displayAnalysis: this.props.toggleAnalysis, - displayProjects: this.props.toggleProjects, - displayImpact: this.props.toggleImpact, - recommendedRetrofitsToggle: {}, - recommendedDeemedToggle: {}, - completedDeemedToggle: {}, - }; - - componentWillUnmount() { - clearTimeout(this.updateNumRows); - } - - handleSearchBuilding = (address) => { - this.props.searchedBuildings(address); - } - - handleAddBuilding = (item) => { - console.log(item); // eslint-disable-line - console.log(this.props.buildings); // eslint-disable-line - this.props.addBuildingToBGroup( - this.props.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.bGroupId, - buildingId, - ); - } - } - - - renderDeleteBuildingButton = (id) => { - if (this.props.bGroup.deleteBGroupBuildingLoading[id]) { - return ( - - ); - } - const disabled = !this.props.user.permissions['delete::BuildingBGroup']; - return ( - (this.handleDeleteBuilding(id))} - style={{ cursor: disabled ? 'not-allowed' : 'pointer' }} - disabled={disabled} - /> - ); - } - - render() { - const { - buildingIdProject, - utilityAccountsStatus, - gatewayDates, - simulationDates, - bbls, - heatPumpScores, - contactAccounts, - contactParentAccounts, - impact, - scoresLoading, - contactLoading, - utilityLoading, - simulationLoading, - gatewayLoading, - impactLoading, - } = this.props; - - let { bGroupBuildings } = this.props.bGroup; - // A generic filter method that ensures that empty rows return false - const genericFilterMethod = (filter, row) => ( - row[filter.id] ? - row[filter.id].toLowerCase().indexOf( // eslint-disable-line - filter.value.toLowerCase() - ) !== -1 - : false - ); - - const listFilterMethod = (filter, row) => { - if (row[filter.id]) { - - return row[filter.id].reduce((acc, val) => ( - val && (acc || val.toLowerCase().indexOf( - filter.value.toLowerCase() - ) !== -1) - ), false); - } - return false; - }; - - const utilityBillFilterMethod = (filter, row) => { - if (filter.value === 'all') { - return true; - } - if (filter.value === 'received') { - return row[filter.id]; - } - return !row[filter.id]; - }; - - const impactRecommendedFilterMethod = (filter, row) => { - if (filter.value === 'all') { - return true; - } - if (filter.value === 'delivered') { - return row[filter.id].length > 0; - } - return row[filter.id].length === 0; - }; - - const impactCompletedFilterMethod = (filter, row) => { - if (filter.value === 'all') { - return true; - } - if (filter.value === 'completed') { - return row[filter.id].length > 0; - } - return row[filter.id].length === 0; - }; - - const impactCompletedRetrofitsFilterMethod = (filter, row) => { - // First check if there is a value and the check box is clicked - if ( - filter.value.check && - (!row[filter.id] || !row[filter.id].length > 0) - ) { - return false; - } - // Then filter by text - if (row[filter.id]) { - // Check if list is empty - if (filter.value.query === '' && row[filter.id].length === 0) { - return true; - } - return row[filter.id].reduce((acc, val) => ( - val && (acc || val.completed.toLowerCase().indexOf( - filter.value.query.toLowerCase() - ) !== -1) - ), false); - } - return false; - }; - - const impactRecommendedRetrofitsFilterMethod = (filter, row) => { - // First check if there is a value and the check box is clicked - if ( - filter.value.check && - (!row[filter.id] || !row[filter.id].length > 0) - ) { - return false; - } - // Then filter by text - if (row[filter.id]) { - // Check if list is empty - if (filter.value.query === '' && row[filter.id].length === 0) { - return true; - } - return row[filter.id].reduce((acc, val) => ( - val && (acc || val.toLowerCase().indexOf( - filter.value.query.toLowerCase() - ) !== -1) - ), false); - } - return false; - }; - - const utilityBillFilter = ({ filter, onChange }) => ( - - ); - - const impactRecommendedFilter = ({ filter, onChange }) => ( - - ); - - const impactCompletedFilter = ({ filter, onChange }) => ( - - ); - - const impactCompletedRetrofitsFilter = ({ filter, onChange }) => { - return ( -
- onChange({ - query: event.target.value, - check: filter ? filter.value.check : false, - })} - value={filter ? filter.value.query : ''} - style={{ width: '75px' }} - /> - {' '} -
- { - onChange({ - query: filter ? filter.value.query : '', - check: filter ? !filter.value.check : true, - }); - }} - /> -
- - Only show buildings with completed retrofits - -
- ); - }; - - const impactRecommendedRetrofitsFilter = ({ filter, onChange }) => { - return ( -
- onChange({ - query: event.target.value, - check: filter ? filter.value.check : false, - })} - value={filter ? filter.value.query : ''} - style={{ width: '75px' }} - /> - {' '} -
- { - onChange({ - query: filter ? filter.value.query : '', - check: filter ? !filter.value.check : true, - }); - }} - /> -
- - Only show buildings with recommended retrofits - -
- ); - }; - - - const columns = [{ - Header: () => ( - - Building Info{' '} - - - ), - columns: [ - { - Header: 'Address', - filterMethod: (filter, row) => ( - row._original.address_list.toLowerCase().indexOf( // eslint-disable-line - filter.value.toLowerCase() - ) !== -1 - ), - Filter: ({ filter, onChange }) => ( - onChange(event.target.value)} - /> - ), - accessor: 'first_address', - Cell: row => ( -
- {row.value} -
- ), - }, - ...(!this.props.user.permissions['view::bgroupBblColumn']) ? [] : [{ - Header: 'BBL', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'bbl', - Cell: row => ( -
- {row.value} -
- ), - }], - ], - }, ...(!this.state.displayScores) ? [] : [{ - Header: () => ( - - Scores{' '} - - - ), - columns: [ - { - Header: 'Heat Pump', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'heat_pump_score', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: 'Building Proximities', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'building_proximities', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: 'Fuel Type', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'fuel_type', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: 'Owner Occupied', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'owner_occupied', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: 'Stable Ownership', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'stable_ownership', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: 'Age of Building', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'building_age', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: 'Pre War/Post War', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'pre_post_war', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: '# of 311 Complaints', - filterable: true, - style: { textAlign: 'center' }, - accessor: 'complaint_311', - Cell: row => ( -
- {row.value} -
- ), - }, - ], - }], ...(!this.state.displayContact) ? [] : [{ - Header: () => ( - - Contact Info{' '} - - - ), - columns: [ - { - Header: 'Owner', - filterMethod: genericFilterMethod, - accessor: 'contact_account', - Cell: row => ( -
- {row.value} -
- ), - }, { - Header: 'Parent Company', - filterMethod: genericFilterMethod, - accessor: 'contact_parent_account', - Cell: row => ( -
- {row.value} -
- ), - }, - ], - }], ...(!this.state.displayAnalysis) ? [] : [{ - Header: () => ( - - Analysis{' '} - - - ), - columns: [ - { - Header: 'Electric Bill', - filterMethod: utilityBillFilterMethod, - Filter: utilityBillFilter, - accessor: 'electric_bill', - style: { textAlign: 'center' }, - Cell: row => ( - row.value ? : null - ), - }, { - Header: 'Gas Bill', - filterMethod: utilityBillFilterMethod, - Filter: utilityBillFilter, - accessor: 'gas_bill', - style: { textAlign: 'center' }, - Cell: row => ( - row.value ? : null - ), - }, { - Header: 'Energy Simulation', - filterMethod: (filter, row) => { - if (filter.value === 'all') { - return true; - } - if (filter.value === 'complete') { - return row[filter.id]; - } - return !row[filter.id]; - }, - Filter: ({ filter, onChange }) => ( - - ), - accessor: 'building_simulation', - style: { textAlign: 'center' }, - Cell: row => ( - row.value ? : null - ), - }, - ], - }], ...(!this.state.displayProjects) ? [] : [{ - Header: () => ( - - Projects{' '} - - - ), - columns: [ - // Only show the sensor install column if the user has the correct permission - ...(!this.props.user.permissions['read::Gateway']) ? [] : [{ - Header: 'Sensor Install', - filterMethod: (filter, row) => { - if (filter.value === 'all') { - return true; - } - if (filter.value === 'installed') { - return row[filter.id]; - } - return !row[filter.id]; - }, - Filter: ({ filter, onChange }) => ( - - ), - accessor: 'gateway_install', - sortMethod: (a, b) => { - if (!b && a) { - return 1; - } else if (b && !a) { - return -1; - } else if (!b && !a) { - return 0; - } - const d1 = new Date(a[0]); - const d2 = new Date(b[0]); - if (d1.getTime() === d2.getTime()) { - return 0; - } - return d1 > d2 ? 1 : -1; - }, - Cell: row => (row.value ? ( -
-
    - {row.value.map((installDate, index) => ( -
  • {installDate}
  • - ))} -
-
- ) : null), - }], { - Header: '# Projects', - filterable: false, - style: { textAlign: 'center' }, - accessor: 'num_projects', - }, { - Header: 'Project Types', - filterMethod: listFilterMethod, - accessor: 'project_types', - Cell: row => (row.value ? ( -
-
    - {row.value.map((type, index) => ( -
  • {type}
  • - ))} -
-
- ) : null), - }, - ], - }], ...(!this.props.user.permissions['read::SfBuildingImpact'] || !this.state.displayImpact) ? [] : [{ - Header: () => ( - - Impact{' '} - - - ), - columns: [ - { - Header: 'Recommended Retrofits', - filterMethod: impactRecommendedRetrofitsFilterMethod, - Filter: impactRecommendedRetrofitsFilter, - accessor: 'recommended_retrofits', - Cell: (row) => { - if (row.value && row.value.length > 0) { - const buildingId = row.original.building_id; - const toggleButton = ( - /* eslint-disable jsx-a11y/no-static-element-interactions */ -
{ - this.setState({ recommendedRetrofitsToggle: { - ...this.state.recommendedRetrofitsToggle, - [buildingId]: !this.state.recommendedRetrofitsToggle[buildingId], - } }); - }} - className="bp-cell-dropdown" - > - {' '} - {this.state.recommendedRetrofitsToggle[buildingId] ? 'Hide' : 'Show'} -
- ); - return ( -
- {toggleButton} - -
    - {row.value.map((val, index) => ( -
  • {val}
  • - ))} -
-
-
- ); - } - return null; - }, - }, { - Header: 'Deemed Savings (recommended)', - filterMethod: impactRecommendedFilterMethod, - Filter: impactRecommendedFilter, - style: { textAlign: 'center' }, - accessor: 'projected_deemed_savings', - Cell: (row) => { - if (row.value && row.value.length > 0) { - const buildingId = row.original.building_id; - const toggleButton = ( - /* eslint-disable jsx-a11y/no-static-element-interactions */ -
{ - this.setState({ recommendedDeemedToggle: { - ...this.state.recommendedDeemedToggle, - [buildingId]: !this.state.recommendedDeemedToggle[buildingId], - } }); - }} - className="bp-cell-dropdown" - > - {' '} - {this.state.recommendedDeemedToggle[buildingId] ? 'Hide' : 'Show'} -
- ); - return ( -
- {toggleButton} - -
    - {row.value.map((val, index) => ( -
  • {val}
  • - ))} -
-
-
- ); - } - return null; - }, - }, { - Header: 'Completed Retrofits', - filterMethod: impactCompletedRetrofitsFilterMethod, - Filter: impactCompletedRetrofitsFilter, - accessor: 'completed_retrofits', - Cell: row => (row.value ? ( -
-
    - {row.value.map((val, index) => ( -
  • {val.completed} ({(new Date(val.completed_date)).toLocaleDateString('en-US')})
  • - ))} -
-
- ) : null), - }, { - Header: 'Deemed Savings (completed)', - filterMethod: impactCompletedFilterMethod, - Filter: impactCompletedFilter, - style: { textAlign: 'center' }, - accessor: 'completed_deemed_savings', - Cell: (row) => { - if (row.value && row.value.length > 0) { - const buildingId = row.original.building_id; - const toggleButton = ( - /* eslint-disable jsx-a11y/no-static-element-interactions */ -
{ - this.setState({ completedDeemedToggle: { - ...this.state.completedDeemedToggle, - [buildingId]: !this.state.completedDeemedToggle[buildingId], - } }); - }} - className="bp-cell-dropdown" - > - {' '} - {this.state.completedDeemedToggle[buildingId] ? 'Hide' : 'Show'} -
- ); - return ( -
- {toggleButton} - -
    - {row.value.map((val, index) => ( -
  • {val}
  • - ))} -
-
-
- ); - } - return null; - }, - }, - ], - }]]; - if (this.props.edit) { - columns.push({ - Header: '', - filterable: false, - accessor: 'delete', - maxWidth: 35, - Cell: row => this.renderDeleteBuildingButton(row.original.id), - }); - } - bGroupBuildings = bGroupBuildings.map((val) => { - const projects = buildingIdProject[val.building_id]; - if (projects) { - val.num_projects = projects.length; - val.project_types = projects.map(proj => (proj.project_type)); - val.bbl = projects.reduce((acc, proj) => { - if (!acc && proj.bbl) { - return proj.bbl; - } - return acc; - }, null); - } else { - val.num_projects = 0; - val.project_types = []; - } - const utilityStatus = utilityAccountsStatus[val.building_id]; - if (utilityStatus) { - val.electric_bill = utilityStatus.electric; - val.gas_bill = utilityStatus.gas; - } - val.gateway_install = gatewayDates[val.building_id]; - val.building_simulation = simulationDates[val.building_id]; - val.bbl = bbls[val.building_id]; - console.log("heatPumpScores rendering"); // eslint-disable-line - console.log(heatPumpScores); // eslint-disable-line - if (heatPumpScores[val.building_id]) { - val.heat_pump_score = heatPumpScores[val.building_id].score; - val.building_proximities = heatPumpScores[val.building_id].building_proximities_cost; - val.fuel_type = heatPumpScores[val.building_id].type_of_fuel; - val.owner_occupied = heatPumpScores[val.building_id].owner_occupied; - val.stable_ownership = heatPumpScores[val.building_id].stable_tenure_of_ownership; - val.building_age = heatPumpScores[val.building_id].building_age; - val.pre_post_war = heatPumpScores[val.building_id].pre_post_war; - val.complaint_311 = heatPumpScores[val.building_id].complaint_311; - } else { - val.heat_pump_score = -1; - val.building_proximities = -1; - val.fuel_type = -1; - val.owner_occupied = -1; - val.stable_ownership = -1; - val.building_age = -1; - val.pre_post_war = -1; - val.complaint_311 = -1; - } - // Contact - val.contact_account = contactAccounts[val.building_id]; - val.contact_parent_account = contactParentAccounts[val.building_id]; - // Project Impact - if (impact[val.building_id]) { - const impactObjects = impact[val.building_id]; - if (impactObjects.diagnostic_recommendations.length > 0) { - val.recommended_retrofits = impactObjects.diagnostic_recommendations; - } else { - val.recommended_retrofits = impactObjects.pns_recommendations; - } - val.completed_retrofits = impactObjects.complete; - // Create a list of all of the projected deemed values - val.projected_deemed_savings = Object.keys(impactObjects.deemed.projected).reduce( - (acc, key) => ([ - ...acc, - ...(impactObjects.deemed.projected[key]) ? [`${impactObjects.deemed.projected[key]} ${key.replace('Projected ', '')}`] : [], - ]), [] - ); - // Create a list of all of the completed deemed values - val.completed_deemed_savings = Object.keys(impactObjects.deemed.completed).reduce( - (acc, key) => ([ - ...acc, - ...(impactObjects.deemed.completed[key]) ? [`${impactObjects.deemed.completed[key]} ${key.replace('Completed ', '')}`] : [], - ]), [] - ); - } else { - val.recommended_retrofits = []; - val.completed_retrofits = []; - val.projected_deemed_savings = []; - val.completed_deemed_savings = []; - } - return val; - }); - - const csvlinkStyle = { - lineHeight: 1.15, - }; - - return ( -
-
-
- - -
-
-
= 0 ? '' : 'none' }}> -
-
{this.state.numRows} buildings
-
- - Export ⬇ -   - - - Toggle Columns - - - { - this.setState({ displayScores: !this.state.displayScores }); - }} - > - - {}} - />{' '} - Scores - - - { - this.setState({ displayContact: !this.state.displayContact }); - }} - > - - {}} - />{' '} - Contact Info - - - { - this.setState({ displayAnalysis: !this.state.displayAnalysis }); - }} - > - - {}} - />{' '} - Analysis - - - { - this.setState({ displayProjects: !this.state.displayProjects }); - }} - > - - {}} - />{' '} - Projects - - - { - this.setState({ displayImpact: !this.state.displayImpact }); - }} - > - - {}} - />{' '} - Impact - - - - -
-
-
- { this.reactTable = reactTable; }} - onFilteredChange={(filter) => { - // Create a bounce function so as to not decrease the speed of the filter. - clearTimeout(this.updateNumRows); - this.updateNumRows = setTimeout( - () => { - ReactGA.event({ - category: 'Building Group', - action: 'Filter', - label: filter.reduce((acc, val) => { - return ( - `${acc}, ${val.id}: ${val.value}` - ); - }, `Building Group: ${this.props.bGroup.bGroupDetail.name}, # Results: ${this.reactTable.state.sortedData.length}`), - }); - this.setState({ - numRows: this.reactTable.state.sortedData.length, - totalRows: this.reactTable.state.sortedData.map((item) => { - delete item._index; // eslint-disable-line - delete item._original; // eslint-disable-line - delete item._nestingLevel; // eslint-disable-line - delete item._subRows; // eslint-disable-line - return item; - }), - }); - }, - 250, - ); - this.props.onBuildingFilter(filter, this.reactTable.state); - }} - noDataText={this.props.bGroup.bGroupDetailLoading ? 'Loading...' : 'No data'} - SubComponent={row => { - const addresses = bGroupBuildings - .filter(i => i.building_id === row.original.building_id) - .reduce((acc, val) => val.address_list, '') - .split(','); - return ( -
- -
-
-

- Address list{' '} - - - -

-
    - {addresses.map(i =>
  • {i}
  • )} -
-
- {buildingIdProject[row.original.building_id] ? ( -
-

- Project list -

-
    - {buildingIdProject[row.original.building_id].map((i) => { - let spanStatus = 'pending'; - if (i.state === 'constructed') { - spanStatus = 'claimed'; - } else if (i.state === 'cancelled') { - spanStatus = 'rejected'; - } - return ( -
  • - { i.state } - {' '} - {i.project_type ? i.project_type : 'Project' } -
  • - ); - })} -
-
- ) : null} -
-
- ); - }} - /> -
-
-
- ); - } -} - -BGroupBuildingTable.propTypes = { - edit: PropTypes.bool, - bGroupId: PropTypes.string, - user: userPropTypes, - buildings: buildingPropTypes, - projects: completeProjectPropTypes, - addBuildingToBGroup: PropTypes.func, - deleteBuildingFromBGroup: PropTypes.func, - /* eslint-disable react/forbid-prop-types */ - bGroup: PropTypes.object, - buildingIdProject: PropTypes.object, - utilityAccountsStatus: PropTypes.object, - gatewayDates: PropTypes.object, - simulationDates: PropTypes.object, - bbls: PropTypes.object, - heatPumpScores: PropTypes.object, - contactAccounts: PropTypes.object, - contactParentAccounts: PropTypes.object, - impact: PropTypes.object, - scoresLoading: PropTypes.bool, - contactLoading: PropTypes.bool, - utilityLoading: PropTypes.bool, - simulationLoading: PropTypes.bool, - gatewayLoading: PropTypes.bool, - impactLoading: PropTypes.bool, - displayToggleColumns: PropTypes.bool, - toggleScores: PropTypes.bool, - toggleContacts: PropTypes.bool, - toggleAnalysis: PropTypes.bool, - toggleProjects: PropTypes.bool, - toggleImpact: PropTypes.bool, - onBuildingFilter: PropTypes.func, -}; -- GitLab