import {PAY_BILL_ERROR, PAY_BILL_PENDING, PAY_BILL_RESET, PAY_BILL_SUCCESS} from "../types/WalletType";

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

export default (state = initialState, action) => {
    switch (action.type) {
        case PAY_BILL_PENDING:
            return {
                ...state,
                loading: true
            }
        case PAY_BILL_SUCCESS:
            return {
                ...state,
                loading: false,
                result: action.result.data,
                error: null
            }
        case PAY_BILL_ERROR:
            return {
                ...state,
                loading: false,
                result: null,
                error: action.result
            }
        case PAY_BILL_RESET:
            return initialState;

        default: {
            return state;
        }
    }
};
