Skip to content

Commit

Permalink
refactor fuel tech groups
Browse files Browse the repository at this point in the history
  • Loading branch information
chienleng committed Jun 17, 2021
1 parent c110a93 commit a435036
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
18 changes: 5 additions & 13 deletions components/ui/FuelTechGroupSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,13 @@

<script>
import { mapGetters } from 'vuex'
const groups = [
'Default',
'Simplified',
'Coal/Gas/Renewables',
'Flexibility',
'Renewable/Fossil',
'Solar/Residual'
]
import { ftGroups, GROUP_DEFAULT } from '@/constants/energy-fuel-techs/'
export default {
data() {
return {
groups,
selected: groups[0]
groups: ftGroups,
selected: ftGroups[0]
}
},
Expand Down Expand Up @@ -73,8 +65,8 @@ export default {
mounted() {
if (this.fuelTechGroupName === 'regions') {
if (this.regionId !== 'nem') {
this.$store.dispatch('fuelTechGroupName', 'Default')
this.selected = 'Default'
this.$store.dispatch('fuelTechGroupName', GROUP_DEFAULT)
this.selected = GROUP_DEFAULT
this.$router.push({ path: `/energy/${this.regionId}` })
} else {
this.selected = this.fuelTechGroupName
Expand Down
2 changes: 2 additions & 0 deletions constants/energy-fuel-techs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Groups[GROUP_FLEXIBILITY] = FlexibilityGroup
Groups[GROUP_RENEWABLE_FOSSIL] = RenewableFossilGroup
Groups[GROUP_SOLAR_RESIDUAL] = SolarResidualGroup

export const ftGroups = Object.keys(Groups)

export function getAllGroups(powerEnergyDomains, type) {
const parsed = {}
Object.keys(Groups).forEach(key => {
Expand Down
10 changes: 10 additions & 0 deletions constants/fuel-tech-group-queries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import _includes from 'lodash.includes'
import { ftGroups, GROUP_DEFAULT } from '@/constants/energy-fuel-techs/'

export function isValidFtGroupQuery(query) {
return _includes(ftGroups, query)
}

export function getDefaultFtGroup() {
return GROUP_DEFAULT
}

0 comments on commit a435036

Please sign in to comment.