import { CREATE_GROUP_PENDING, CREATE_GROUP_SUCCESS, CREATE_GROUP_ERROR, CREATE_GROUP_RESET } from "../types/NanoCreditType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case CREATE_GROUP_PENDING: return {
               ...state,
               loading: true
          }
          case CREATE_GROUP_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case CREATE_GROUP_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case CREATE_GROUP_RESET: return initialState;

          default: {
               return state;
          }
     }
};
