outOfStockReducer.js 1002 Bytes

'use strict';
/**
 * ## Imports
 *
 * InitialState
 */
import InitialState from './outOfStockInitialState';

import Immutable, {List, Record} from 'immutable';

const {

	STOCKOUT_REQUEST,
	STOCKOUT_SUCCESS,
	STOCKOUT_FAILURE,

	SET_LACK_NUM,
	SET_INITIAL_RES,

} = require('../../constants/actionTypes').default;

const initialState = new InitialState;

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

    switch (action.type) {
		case STOCKOUT_REQUEST:{
			return state;
		}
		case STOCKOUT_SUCCESS:{
			return state;
		}
		case STOCKOUT_FAILURE:{
			return state;
		}
		case SET_LACK_NUM:{
			return state.set('lackNum', action.payload);
		}
		case SET_INITIAL_RES:{
			return state.set('initialRes', Immutable.fromJS(action.payload));
		}
		return state;
	}

    return state;
}