// @flow
import {createSelector} from 'reselect'

import selectCurrentScenario from './current-scenario'

export default createSelector(
  (state) => state.project && state.project.currentProject,
  selectCurrentScenario,
  (_, props = {}) => props.params,
  (currentProject = {}, currentScenario = {}, routeParams = {}) =>
    currentProject.id || currentScenario.projectId || routeParams.projectId
)

// @flow
import {createSelector} from 'reselect'

import selectCurrentScenario from './current-scenario'

export default createSelector(
  (state) => state.project && state.project.currentProject,
  selectCurrentScenario,
  (_, props = {}) => props.params,
  (currentProject = {}, currentScenario = {}, routeParams = {}) =>
    routeParams.projectId || currentProject.id || currentScenario.projectId
)

Select project id from route parameters first
fix(project): Select project id from route parameters first

Fixes a problem where project was set in wrong order.

closes #535
