af83/chouette-core

View on GitHub
app/packs/src/routes/reducers/deletedStopPoints.js

Summary

Maintainability
A
0 mins
Test Coverage
const deletedStopPoints = (state = [], action, length) => {
  switch (action.type) {
    case 'DELETE_STOP':
      const deletedStopPoint = { id: action.stopPointId, _destroy: true }

      //stopPoint is not persited don't need to track it
      if (!action.stopPointId) return state

      if (state.find(sp => action.stopPointId === sp.id)) return state

      return state.concat(deletedStopPoint)
    default:
      return state
  }
}

export default deletedStopPoints