vendorReducers.js 698 Bytes
import { UPDATE_VENDOR_DETAILS_FAIL, UPDATE_VENDOR_DETAILS_REQUEST, UPDATE_VENDOR_DETAILS_SUCCESS, CLEAR_ERRORS } from "../constants/vendorConstants";

export const updateVendorReducer = (state = {}, action) => {
  switch (action.type) {
    case UPDATE_VENDOR_DETAILS_REQUEST:
      return { loading: true };

    case UPDATE_VENDOR_DETAILS_SUCCESS:
      return {
        loading: false,
        updatedVendorData: action.payload
      };

    case UPDATE_VENDOR_DETAILS_FAIL:
      return {
        loading: false,
        error: action.payload.error.message
      };

    case CLEAR_ERRORS:
      return {
        ...state,
        error: null
      };

    default:
      return state;
  }
};