Skip to content

Commit

Permalink
Merge pull request #244 from ConsumerDataStandardsAustralia/bugfix/ad…
Browse files Browse the repository at this point in the history
…d-delete-datasource

Redefine local var in each case block
  • Loading branch information
sumayahasancds authored Nov 21, 2023
2 parents 0c9e60e + d1bbd18 commit 8afb73c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/store/data-source/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,30 @@ export default function dataSources(state=[], action) {
case fulfilled(SYNC_DATA_SOURCES):
persistSavedDataSources(action.payload)
return action.payload
case SAVE_DATA_SOURCE:
let dataSources = state.map((dataSource, index) => (index === action.index ? {...action.payload, unsaved: false} : dataSource));
case SAVE_DATA_SOURCE: {
const dataSources = state.map((dataSource, index) => (index === action.index ? {...action.payload, unsaved: false} : dataSource))
persistSavedDataSources(dataSources)
return dataSources
case DELETE_DATA_SOURCE:
dataSources = [...state]
}
case DELETE_DATA_SOURCE: {
const dataSources = [...state]
dataSources[action.index].deleted = true
persistSavedDataSources(dataSources)
return dataSources
}
case MODIFY_DATA_SOURCE_NAME:
case MODIFY_DATA_SOURCE_ICON:
case ENABLE_DATA_SOURCE:
dataSources = state.map((dataSource, index) => (index === action.index ? {...action.payload} : dataSource));
case ENABLE_DATA_SOURCE: {
const dataSources = state.map((dataSource, index) => (index === action.index ? {...action.payload} : dataSource))
persistSavedDataSources(dataSources)
return dataSources
}
case MODIFY_DATA_SOURCE_URL:
case MODIFY_DATA_SOURCE_ENERGY_PRD_URL:
dataSources = state.map((dataSource, index) => (index === action.index ? {...action.payload, unsaved: true} : dataSource))
case MODIFY_DATA_SOURCE_ENERGY_PRD_URL: {
const dataSources = state.map((dataSource, index) => (index === action.index ? {...action.payload, unsaved: true} : dataSource))
persistSavedDataSources(dataSources)
return dataSources
}
default:
return state
}
Expand Down

0 comments on commit 8afb73c

Please sign in to comment.