aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/view.js
blob: b56561d0bf765b0053ba6d766865a755e92a3999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import ReduxThunk from 'redux-thunk'

import { SELECT_FLOW } from './flows'
const ACTIVE_MENU = 'ACTIVE_MENU'


const defaultState = {
    active_menu: 'Start'
}
export default function reducer(state = defaultState, action) {
    switch (action.type) {
        case ACTIVE_MENU:
            return {
                ...state,
                active_menu: action.active_menu
            }
        case SELECT_FLOW:
            if (!action.currentSelection != !action.flowId){
                return{
                    ...state,
                    active_menu: action.flowId ? 'Flow' : (state.active_menu == 'Flow' ? 'Start' : state.active_menu)
                }
            }
            return state
        default:
            return state
    }
}

export function setActiveMenu(active_menu) {
    return {
        type: ACTIVE_MENU,
        active_menu
    }
}