activitiesReducer.js 761 Bytes
import { CREATE_ACTIVITY_FAIL, CREATE_ACTIVITY_REQUEST, CREATE_ACTIVITY_SUCCESS } from "../constants/activitiesConstants";
import { CLEAR_ERRORS } from "../constants/vendorConstants";

export const createActivityReducer = (state = {}, action) => {
    switch (action.type) {
      case CREATE_ACTIVITY_REQUEST:
        return { loading: true };
  
      case CREATE_ACTIVITY_SUCCESS:
        return {
          loading: false,
          activityData: action.payload
        };
  
      case CREATE_ACTIVITY_FAIL:
        return {
          loading: false,
          error: action.payload.error.message
        };
  
      case CLEAR_ERRORS:
        return {
          ...state,
          error: null
        };
  
      default:
        return state;
    }
  };