aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/ui.js
blob: c17e042b47cd0f521291ad10a7ca6ca9f69d68e2 (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
37
38
39
40
41
42
import {SELECT_FLOW} from "./flows"
export const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU';


const defaultState = {
    activeMenu: 'Start',
}
export default function reducer(state = defaultState, action) {
    switch (action.type) {
        case SET_ACTIVE_MENU:
            return {
                ...state,
                activeMenu: action.activeMenu
            }
        case SELECT_FLOW:
            let isNewSelect = (action.flowId && !action.currentSelection)
            let isDeselect = (!action.flowId && action.currentSelection)
            if(isNewSelect) {
                return {
                    ...state,
                    activeMenu: "Flow"
                }
            }
            if(isDeselect && state.activeMenu === "Flow") {
                return {
                    ...state,
                    activeMenu: "Start"
                }
            }
            return state
        default:
            return state
    }
}

export function setActiveMenu(activeMenu) {
    return {
        type: SET_ACTIVE_MENU,
        activeMenu
    }
}