/* like mutation */
import ACTION from '../actions/actiontsTypes';

const initialState = {
    data: [],
    isFetching: false,
    error: null
};

export default function (state = initialState, action) {
    switch (action.type) {
        case ACTION.DYNAMIC_SEARCH_GOODS_REQUEST: {
            return {
                ...state,
                isFetching: true,
                error: null
            }
        }
        case ACTION.DYNAMIC_SEARCH_GOODS_RESPONSE: {
            return {
                ...state,
                data: action.data,
                isFetching: false,
                error: null
            }
        }
        case ACTION.DYNAMIC_SEARCH_GOODS_ERROR: {
            return {
                ...state,
                error: action.error,
                isFetching: false
            }
        }
        default: {
            return state
        }
    }
}

