import {
    REATTACH_ACCOUNT_ERROR,
    REATTACH_ACCOUNT_PENDING,
    REATTACH_ACCOUNT_RESET,
    REATTACH_ACCOUNT_SUCCESS
} from "../types/WalletType";

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

export default (state = initialState, action) => {
    switch (action.type) {
        case REATTACH_ACCOUNT_PENDING:
            return {
                ...state,
                loading: true
            }
        case REATTACH_ACCOUNT_SUCCESS:
            return {
                ...state,
                loading: false,
                result: action.result.data,
                error: null
            }
        case REATTACH_ACCOUNT_ERROR:
            return {
                ...state,
                loading: false,
                result: null,
                error: action.result
            }
        case REATTACH_ACCOUNT_RESET:
            return initialState;

        default: {
            return state;
        }
    }
};
