import {
    GET_OPERATOR_LIST_ERROR,
    GET_OPERATOR_LIST_PENDING,
    GET_OPERATOR_LIST_RESET,
    GET_OPERATOR_LIST_SUCCESS
} from "../types/WalletType";

const initialState = {
    loading: false,
    result: null,
    error: null
};

export default (state = initialState, action) => {
    switch (action.type) {
        case GET_OPERATOR_LIST_PENDING:
            return {
                ...state,
                loading: true
            }
        case GET_OPERATOR_LIST_SUCCESS:
            return {
                ...state,
                loading: false,
                result: action.result.data,
                error: null
            }
        case GET_OPERATOR_LIST_ERROR:
            return {
                ...state,
                loading: false,
                result: null,
                error: action.result
            }
        case GET_OPERATOR_LIST_RESET:
            return initialState;

        default: {
            return state;
        }
    }
};
