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

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

export default function (state = initialState, action) {

    switch (action.type) {
        case ACTION.HISTORY_ORDERS_REQUEST: {
            return {
                ...state,
                isFetching: true,
                error: null
            }
        }
        case ACTION.HISTORY_ORDERS_RESPONSE: {

            return {
                ...state,
                historyOrders: action.data,
                isFetching: false,
                error: null
            }
        }
        case ACTION.HISTORY_ORDERS_ERROR: {
            return {
                ...state,
                error: action.error.response.data,
                isFetching: false
            }
        }
        default: {
            return state
        }
    }
}

