import {
    REQUEST_ORDERS,
    RECEIVE_ORDERS
} from '../../constants/dashboardConstants';

const moduleReducers = {};

moduleReducers[REQUEST_ORDERS] = (state, action) => {
    return Object.assign({}, state, {
        isLoading: action.isLoading
    });
};

moduleReducers[RECEIVE_ORDERS] = (state, action) => {
    return Object.assign({}, state, {
        orders: action.orders,
        isLoading: action.isLoading
    });
};

const ordersCentralReducer = (state = {}, action) => {

    return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
};

export default ordersCentralReducer;
