import { ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_PENDING, ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_SUCCESS, ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_ERROR, ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_RESET } 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_GET_COMMISSION_PENDING: return {
               ...state,
               loading: true
          }
          case ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case ENVOIE_WALLET_TO_CARD_USER_GET_COMMISSION_RESET: return initialState;

          default: {
               return state;
          }
     }
};
