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

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

export default function (state = initialState, action) {
    switch (action.type) {
        case ACTION.FILTER_ELEMENTS_REQUEST: {
            return {
                ...state,
                isFetching: action.isFetching,
                error: null
            }
        }
        case ACTION.FILTER_ELEMENTS_RESPONSE: {

            return {
                ...state,
                filterElements: action.data,
                isFetching: false,
                error: null
            }
        }
        case ACTION.FILTER_ELEMENTS_ERROR: {
            return {
                ...state,
                error: action.error,
                isFetching: false
            }
        }
        default: {
            return state
        }
    }
}

