import { TREAT_CREDIT_CANCEL_PENDING, TREAT_CREDIT_CANCEL_SUCCESS, TREAT_CREDIT_CANCEL_ERROR, TREAT_CREDIT_CANCEL_RESET } from "../types/CreditManageType";

const initialState = {
     loadingCancelDemand: false,
     resultCancelDemand: null,
     errorCancelDemand: null,
};

export default (state = initialState, action) => {
     switch (action.type) {
          case TREAT_CREDIT_CANCEL_PENDING: return {
               ...state,
               loadingCancelDemand: true
          }
          case TREAT_CREDIT_CANCEL_SUCCESS: return {
               ...state,
               loadingCancelDemand: false,
               resultCancelDemand: action.result.data,
               errorCancelDemand: null
          }
          case TREAT_CREDIT_CANCEL_ERROR: return {
               ...state,
               loadingCancelDemand: false,
               resultCancelDemand: null,
               errorCancelDemand: action.result
          }

          case TREAT_CREDIT_CANCEL_RESET: return initialState;

          default: {
               return state;
          }

     }
};
