guideReducer.js 852 Bytes
/**
 * # guideReducer.js
 *
 * The reducer for all the actions from the various log states
 */
'use strict';
/**
 * ## Imports
 *
 * InitialState
 */
import InitialState from './guideInitialState';

/**
 * Device actions to test
 */
const {
    GET_GUIDE_DISPLAY,
    SET_GUIDE_DISPLAY
} = require('../../constants/actionTypes').default;

const initialState = new InitialState;

/**
 * ## guideReducer function
 * @param {Object} state - initialState
 * @param {Object} action - type and payload
 */
export default function guideReducer(state = initialState, action) {
    if (!(state instanceof InitialState)) return initialState.merge(state);

    switch (action.type) {

        case GET_GUIDE_DISPLAY:
        case SET_GUIDE_DISPLAY:
        const status = action.payload;
        return state.set('displayed', status);

    }

    return state;
}