-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP on the emissions and energy calculator
- Loading branch information
Showing
4 changed files
with
165 additions
and
25 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/api/src/graphql/resolvers/mutations/update-vocabulary/trees/emission-types.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
parent,term,tree | ||
,Emission,emissionTypes | ||
Emission,Combustion,emissionTypes | ||
Emission,Process,emissionTypes | ||
Emission,Fugitive emissions,emissionTypes | ||
Emission,"Agriculture, forrestry, and fisheries",emissionTypes | ||
Emission,Waste,emissionTypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 81 additions & 3 deletions
84
src/client/src/pages/submit-project/forms/mitigation/calculators/emissions/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,83 @@ | ||
import MultiSelect from '../../../../../../components/multiselect' | ||
import { WithControlledVocabulary } from '../../../../gql-form-binder' | ||
import Multiselect from '../../../../../../components/multiselect' | ||
import { DatePicker } from '@material-ui/pickers' | ||
import Grid from '@material-ui/core/Grid' | ||
|
||
export default ({ calculator, updateCalculator }) => { | ||
return 'hi' | ||
export default ({ calculator = {}, updateCalculator = {} }) => { | ||
const { emissionTypes = [], startYear = null, endYear = null } = calculator | ||
|
||
return ( | ||
<> | ||
<WithControlledVocabulary root="Emission" tree="emissionTypes"> | ||
{({ options }) => { | ||
return ( | ||
<Multiselect | ||
id="emissions-calculator" | ||
options={options.map(({ term }) => term)} | ||
value={emissionTypes} | ||
helperText="Select all applicable emissions types" | ||
label={'Emissions types'} | ||
setValue={value => | ||
updateCalculator( | ||
Object.assign( | ||
{ ...calculator }, | ||
{ | ||
emissionTypes: value, | ||
} | ||
) | ||
) | ||
} | ||
/> | ||
) | ||
}} | ||
</WithControlledVocabulary> | ||
|
||
{/* DATE RANGE */} | ||
<Grid container spacing={2}> | ||
{/* START DATE */} | ||
<Grid item xs={12} sm={6}> | ||
<DatePicker | ||
fullWidth | ||
inputVariant="outlined" | ||
margin="normal" | ||
clearable | ||
variant="dialog" | ||
views={['year']} | ||
animateYearScrolling | ||
format="yyyy" | ||
placeholder={'Start year'} | ||
label={'Start year'} | ||
id="emission-calculator-mitigation-start" | ||
helperText={'What year did/will the mitigation project start?'} | ||
value={startYear} | ||
onChange={value => | ||
updateCalculator(Object.assign({ ...calculator }, { startYear: value })) | ||
} | ||
/> | ||
</Grid> | ||
|
||
{/* END DATE */} | ||
<Grid item xs={12} sm={6}> | ||
<DatePicker | ||
fullWidth | ||
inputVariant="outlined" | ||
margin="normal" | ||
clearable | ||
variant="dialog" | ||
views={['year']} | ||
animateYearScrolling | ||
format="yyyy" | ||
placeholder={'End year'} | ||
label={'End year'} | ||
id="emission-calculator-mitigation-end" | ||
helperText={'What year did/will the mitigation project end?'} | ||
value={endYear} | ||
onChange={value => | ||
updateCalculator(Object.assign({ ...calculator }, { endYear: value })) | ||
} | ||
/> | ||
</Grid> | ||
</Grid> | ||
</> | ||
) | ||
} |
94 changes: 73 additions & 21 deletions
94
src/client/src/pages/submit-project/forms/mitigation/calculators/energy/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,83 @@ | ||
import { WithControlledVocabulary } from '../../../../gql-form-binder' | ||
import Multiselect from '../../../../../../components/multiselect' | ||
import { DatePicker } from '@material-ui/pickers' | ||
import Grid from '@material-ui/core/Grid' | ||
|
||
export default ({ calculator = {}, updateCalculator = {} }) => { | ||
const { renewableTypes = [] } = calculator | ||
const { renewableTypes = [], startYear = null, endYear = null } = calculator | ||
|
||
return ( | ||
<WithControlledVocabulary root="Energy source" tree="renewableTypes"> | ||
{({ options }) => { | ||
return ( | ||
<Multiselect | ||
id="energy-calculator" | ||
options={options.map(({ term }) => term)} | ||
value={renewableTypes} | ||
label={'Select renewable types'} | ||
setValue={value => { | ||
updateCalculator( | ||
Object.assign( | ||
{ ...calculator }, | ||
{ | ||
renewableTypes: value, | ||
} | ||
<> | ||
<WithControlledVocabulary root="Energy source" tree="renewableTypes"> | ||
{({ options }) => { | ||
return ( | ||
<Multiselect | ||
id="energy-calculator" | ||
options={options.map(({ term }) => term)} | ||
value={renewableTypes} | ||
helperText="Select all applicable renewable energy types" | ||
label={'Renewable energy types'} | ||
setValue={value => | ||
updateCalculator( | ||
Object.assign( | ||
{ ...calculator }, | ||
{ | ||
renewableTypes: value, | ||
} | ||
) | ||
) | ||
) | ||
}} | ||
} | ||
/> | ||
) | ||
}} | ||
</WithControlledVocabulary> | ||
|
||
{/* DATE RANGE */} | ||
<Grid container spacing={2}> | ||
{/* START DATE */} | ||
<Grid item xs={12} sm={6}> | ||
<DatePicker | ||
fullWidth | ||
inputVariant="outlined" | ||
margin="normal" | ||
clearable | ||
variant="dialog" | ||
views={['year']} | ||
animateYearScrolling | ||
format="yyyy" | ||
placeholder={'Start year'} | ||
label={'Start year'} | ||
id="energy-calculator-mitigation-start" | ||
helperText={'What year did/will the mitigation project start?'} | ||
value={startYear} | ||
onChange={value => | ||
updateCalculator(Object.assign({ ...calculator }, { startYear: value })) | ||
} | ||
/> | ||
</Grid> | ||
|
||
{/* END DATE */} | ||
<Grid item xs={12} sm={6}> | ||
<DatePicker | ||
fullWidth | ||
inputVariant="outlined" | ||
margin="normal" | ||
clearable | ||
variant="dialog" | ||
views={['year']} | ||
animateYearScrolling | ||
format="yyyy" | ||
placeholder={'End year'} | ||
label={'End year'} | ||
id="energy-calculator-mitigation-end" | ||
helperText={'What year did/will the mitigation project end?'} | ||
value={endYear} | ||
onChange={value => | ||
updateCalculator(Object.assign({ ...calculator }, { endYear: value })) | ||
} | ||
/> | ||
) | ||
}} | ||
</WithControlledVocabulary> | ||
</Grid> | ||
</Grid> | ||
</> | ||
) | ||
} |