import { ASK_NANO_CREDIT_PENDING, ASK_NANO_CREDIT_SUCCESS, ASK_NANO_CREDIT_ERROR, ASK_NANO_CREDIT_RESET } from "../types/NanoCreditType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case ASK_NANO_CREDIT_PENDING: return {
               ...state,
               loading: true
          }
          case ASK_NANO_CREDIT_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case ASK_NANO_CREDIT_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case ASK_NANO_CREDIT_RESET: return initialState;

          default: {
               return state;
          }
     }
};
