import {NAVIGATE} from './actions'
import {loadRegionByCode} from './region'

/* Action creators */
export function navigate(match = {}) {
  return dispatch => {
    const {params} = match
    if (params.region) {
      dispatch(loadRegionByCode(params.region))
    }
    dispatch({
      type: NAVIGATE,
      match
    })
  }
}

import {NAVIGATE} from './actions'
import {loadRegionByCode} from './region'

/* Action creators */
export function navigate(match = {}) {
  return dispatch => {
    const {params} = match
    if (params.region) {
      const [regionCode] = params.region.split('-')
      dispatch(loadRegionByCode(regionCode))
    }
    dispatch({
      type: NAVIGATE,
      match
    })
  }
}

Allow region name in region part of url
Allow region name in region part of url
