diff --git a/src/containers/BGroup/BGroupBuildingTable.js b/src/containers/BGroup/BGroupBuildingTable.js index 41b32d3e66ed6f9476ddfa476a1a4b6fb3d0d6a3..115457370af351129e3b2c10baf55fda683d27d1 100644 --- a/src/containers/BGroup/BGroupBuildingTable.js +++ b/src/containers/BGroup/BGroupBuildingTable.js @@ -116,6 +116,26 @@ export default class BGroupBuildingTable extends Component { 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 utilityBillFilter = ({ filter, onChange }) => ( ); + const impactRecommendedFilter = ({ filter, onChange }) => ( + + ); + const impactCompletedFilter = ({ filter, onChange }) => ( + + ); const columns = [{ Header: () => ( @@ -243,7 +285,7 @@ export default class BGroupBuildingTable extends Component { value={filter ? filter.value : 'all'} > - + ), @@ -348,7 +390,8 @@ export default class BGroupBuildingTable extends Component { columns: [ { Header: 'Recommended Retrofits', - filterMethod: listFilterMethod, + filterMethod: impactRecommendedFilterMethod, + Filter: impactRecommendedFilter, accessor: 'recommended_retrofits', Cell: (row) => { if (row.value && row.value.length > 0) { @@ -390,7 +433,8 @@ export default class BGroupBuildingTable extends Component { }, }, { Header: 'Deemed Savings (recommended)', - filterable: false, + filterMethod: impactRecommendedFilterMethod, + Filter: impactRecommendedFilter, style: { textAlign: 'center' }, accessor: 'projected_deemed_savings', Cell: (row) => { @@ -433,16 +477,8 @@ export default class BGroupBuildingTable extends Component { }, }, { Header: 'Completed Retrofits', - filterMethod: (filter, row) => { - if (row[filter.id]) { - return row[filter.id].reduce((acc, val) => ( - val && (acc || val.completed.toLowerCase().indexOf( - filter.value.toLowerCase() - ) !== -1) - ), false); - } - return false; - }, + filterMethod: impactCompletedFilterMethod, + Filter: impactCompletedFilter, accessor: 'completed_retrofits', Cell: row => (row.value ? (
@@ -455,7 +491,8 @@ export default class BGroupBuildingTable extends Component { ) : null), }, { Header: 'Deemed Savings (completed)', - filterable: false, + filterMethod: impactCompletedFilterMethod, + Filter: impactCompletedFilter, style: { textAlign: 'center' }, accessor: 'completed_deemed_savings', Cell: (row) => {