Liferay.Loader.define("commerce-bom-admin-web@4.0.30/js/middleware/index.es", ['module', 'exports', 'require', '../actions/app.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    var _app = require("../actions/app.es");

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * The contents of this file are subject to the terms of the Liferay Enterprise
     * Subscription License ("License"). You may not use this file except in
     * compliance with the License. You can obtain a copy of the License by
     * contacting Liferay, Inc. See the License for the specific language governing
     * permissions and limitations under the License, including but not limited to
     * distribution rights of the Software.
     */
    var applyMiddleware = function applyMiddleware(dispatch) {
      return function (action) {
        if (action.type.indexOf('Fulfilled') > -1) {
          _app.actions.setError(dispatch)(null);

          _app.actions.setLoading(dispatch)(false);
        }

        if (action.type.indexOf('Pending') > -1) {
          _app.actions.setLoading(dispatch)(true);
        }

        if (action.type.indexOf('Rejected') > -1) {
          _app.actions.setError(dispatch)(action.payload.message);

          _app.actions.setLoading(dispatch)(false);
        }

        dispatch(action);
      };
    };

    var _default = applyMiddleware;
    exports.default = _default;
    //# sourceMappingURL=index.es.js.map
  }
});
//# sourceMappingURL=index.es.js.map