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



const initialState = new InitialState;
const {
    MESSAGE_DETAIL,
} = require('../../constants/actionTypes').default;
/**
 * ## guideReducer function
 * @param {Object} state - initialState
 * @param {Object} action - type and payload
 */
export default function messageReducer(state = initialState, action) {
    if (!(state instanceof InitialState)) return initialState.merge(state);

    switch (action.type) {
		case MESSAGE_DETAIL:{
			let nextState =  state.setIn(['messageDetail', 'title'], action.payload.title)
								.setIn(['messageDetail', 'content'], action.payload.content)
								.setIn(['messageDetail', 'time'], action.payload.time);
			return nextState;
		}

    }

    return state;
}