import { GET_NANO_CREDIT_DEMAND_DURATION_PENDING, GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS, GET_NANO_CREDIT_DEMAND_DURATION_ERROR, GET_NANO_CREDIT_DEMAND_DURATION_RESET } from "../types/NanoCreditType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case GET_NANO_CREDIT_DEMAND_DURATION_PENDING: return {
               ...state,
               loading: true
          }
          case GET_NANO_CREDIT_DEMAND_DURATION_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case GET_NANO_CREDIT_DEMAND_DURATION_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case GET_NANO_CREDIT_DEMAND_DURATION_RESET: return initialState;

          default: {
               return state;
          }
     }
};
