import { ENVOIE_WALLET_TO_CARD_USER_SUCCESS, ENVOIE_WALLET_TO_CARD_USER_PENDING, ENVOIE_WALLET_TO_CARD_USER_RESET, ENVOIE_WALLET_TO_CARD_USER_ERROR } from "../types/EnvoieUserType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case ENVOIE_WALLET_TO_CARD_USER_PENDING: return {
               ...state,
               loading: true
          }
          case ENVOIE_WALLET_TO_CARD_USER_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case ENVOIE_WALLET_TO_CARD_USER_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case ENVOIE_WALLET_TO_CARD_USER_RESET: return initialState;

          default: {
               return state;
          }
     }
};
