import { REFUND_CREDIT_DEMAND_USER_PENDING, REFUND_CREDIT_DEMAND_USER_RESET, REFUND_CREDIT_DEMAND_USER_SUCCESS, REFUND_CREDIT_DEMAND_USER_ERROR } from "../types/NanoCreditType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case REFUND_CREDIT_DEMAND_USER_PENDING: return {
               ...state,
               loading: true
          }
          case REFUND_CREDIT_DEMAND_USER_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case REFUND_CREDIT_DEMAND_USER_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case REFUND_CREDIT_DEMAND_USER_RESET: return initialState;

          default: {
               return state;
          }
     }
};
