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

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

export default function (state = initialState, action) {
    switch (action.type) {
        case ACTION.ADMIN_ORDERS_REQUEST: {
            return {
                ...state,
                numberPage: action.numberPage,
                isFetching: true,
                error: null
            }
        }
        case ACTION.ADMIN_ORDERS_RESPONSE: {
            return {
                ...state,
                data: action.data,
                isFetching: false,
                error: null
            }
        }
        case ACTION.ADMIN_ORDERS_ERROR: {
            return {
                ...state,
                error: action.error,
                isFetching: false
            }
        }
        default: {
            return state
        }
    }
}

