import { NEW_ROUTE, GO_BACK } from '../Actions/actions_routing.js'
import routes from '../Utils/routes.js'

const initialState = {
  name: routes.INTERESTS,
  history: [ routes.INTERESTS ]
}

export default (state = initialState, action) => {
  const { history } = state
  switch (action.type) {
  case NEW_ROUTE:
    return {
      name: action.route.name,
      history: history.concat(action.route.name)
    }
  case GO_BACK:
    const newRoute = history.slice(-2)[0]
    const newHistory = history.slice(0, -1)
    return {
      name: newRoute,
      history: newHistory
    }
  default:
    return state
  }
}

// let state = {
//   route: { name: 'login' },
//   history: [ 'name1', 'name2' ]
// }

@@ -131,16 +131,94 @@
 %0A  name:
+ routes.HUB,%0A  history: %5B routes.HUB %5D%0A%7D%0A%0A// const initialState = %7B%0A//   name:
  routes.
@@ -228,16 +228,19 @@
 ERESTS,%0A
+// 
   histor
@@ -263,16 +263,19 @@
 RESTS %5D%0A
+// 
 %7D%0A%0Aexpor

change default initial route to HUB