colouring-montreal/app/src/frontend/building/data-containers/sustainability.tsx

114 lines
4.4 KiB
TypeScript
Raw Normal View History

2019-08-14 17:10:25 -04:00
import React, { Fragment } from 'react';
import { dataFields } from '../../data_fields';
2019-11-07 02:39:26 -05:00
import NumericDataEntry from '../data-components/numeric-data-entry';
import SelectDataEntry from '../data-components/select-data-entry';
2020-08-04 14:15:26 -04:00
import Verification from '../data-components/verification';
2019-11-07 02:39:26 -05:00
import withCopyEdit from '../data-container';
import { CategoryViewProps } from './category-view-props';
const EnergyCategoryOptions = ["A", "B", "C", "D", "E", "F", "G"];
const BreeamRatingOptions = [
'Outstanding',
'Excellent',
'Very good',
'Good',
'Pass',
'Unclassified'
];
/**
* Sustainability view/edit section
*/
const SustainabilityView: React.FunctionComponent<CategoryViewProps> = (props) => {
return (
<Fragment>
<SelectDataEntry
title={dataFields.sust_breeam_rating.title}
slug="sust_breeam_rating"
value={props.building.sust_breeam_rating}
tooltip={dataFields.sust_breeam_rating.tooltip}
options={BreeamRatingOptions}
2019-10-16 16:13:50 -04:00
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
/>
2020-08-04 14:15:26 -04:00
<Verification
slug="sust_breeam_rating"
allow_verify={props.user !== undefined && props.building.sust_breeam_rating !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("sust_breeam_rating")}
user_verified_as={props.user_verified.sust_breeam_rating}
verified_count={props.building.verified.sust_breeam_rating}
/>
<SelectDataEntry
title={dataFields.sust_dec.title}
slug="sust_dec"
value={props.building.sust_dec}
tooltip={dataFields.sust_dec.tooltip}
options={EnergyCategoryOptions}
2019-10-16 16:13:50 -04:00
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
/>
2020-08-04 14:15:26 -04:00
<Verification
slug="sust_dec"
allow_verify={props.user !== undefined && props.building.sust_dec !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("sust_dec")}
user_verified_as={props.user_verified.sust_dec}
verified_count={props.building.verified.sust_dec}
/>
<SelectDataEntry
title={dataFields.sust_aggregate_estimate_epc.title}
slug="sust_aggregate_estimate_epc"
value={props.building.sust_aggregate_estimate_epc}
tooltip={dataFields.sust_aggregate_estimate_epc.tooltip}
options={EnergyCategoryOptions}
disabled={true}
2019-10-16 16:13:50 -04:00
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
/>
2020-08-04 14:15:26 -04:00
<NumericDataEntry
title={dataFields.sust_retrofit_date.title}
slug="sust_retrofit_date"
value={props.building.sust_retrofit_date}
tooltip={dataFields.sust_retrofit_date.tooltip}
step={1}
min={1086}
max={new Date().getFullYear()}
2019-10-16 16:13:50 -04:00
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
/>
2020-08-04 14:15:26 -04:00
<Verification
slug="sust_retrofit_date"
allow_verify={props.user !== undefined && props.building.sust_retrofit_date !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("sust_retrofit_date")}
user_verified_as={props.user_verified.sust_retrofit_date}
verified_count={props.building.verified.sust_retrofit_date}
/>
<NumericDataEntry
title={dataFields.sust_life_expectancy.title}
slug="sust_life_expectancy"
value={props.building.sust_life_expectancy}
step={1}
min={1}
disabled={true}
2019-10-16 16:13:50 -04:00
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
/>
</Fragment>
);
2019-11-07 03:13:30 -05:00
};
const SustainabilityContainer = withCopyEdit(SustainabilityView);
export default SustainabilityContainer;