import { LINK_CARD_PENDING, LINK_CARD_SUCCESS, LINK_CARD_ERROR, LINK_CARD_RESET } from "../types/WalletType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case LINK_CARD_PENDING: return {
               ...state,
               loading: true
          }
          case LINK_CARD_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case LINK_CARD_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case LINK_CARD_RESET: return initialState;

          default: {
               return state;
          }
     }
};
