Liferay.Loader.define("@liferay/commerce-warehouse-web@4.0.41/js/addCommerceInventoryWarehouse",["module","exports","require","commerce-frontend-js/ServiceProvider/index","commerce-frontend-js/utilities/eventsDefinitions","frontend-js-web"],(function(e,t,a){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function _default({defaultLanguageId:e,editCommerceInventoryWarehousePortletURL:t,namespace:a}){const i=r.default.AdminInventoryAPI("v1"),s=document.getElementById("".concat(a,"fm"));s.addEventListener("submit",(r=>{r.preventDefault();const c=s.querySelector("#".concat(a,"name")).value;if(c)return i.addWarehouse({active:!1,name:{[e]:c}}).then((e=>{const r=(0,o.createPortletURL)(t);r.searchParams.append("".concat(a,"commerceInventoryWarehouseId"),e.id),r.searchParams.append("p_auth",Liferay.authToken),window.parent.Liferay.fire(n.CLOSE_MODAL,{redirectURL:r.toString(),successNotification:{message:Liferay.Language.get("your-request-completed-successfully"),showSuccessNotification:!0}})})).catch((e=>{const t={"please-enter-a-valid-name":Liferay.Language.get("please-enter-a-valid-name")};(0,o.openToast)({message:t[e.message]||Liferay.Language.get("an-unexpected-error-occurred"),title:Liferay.Language.get("error"),type:"danger"})}));(0,o.openToast)({message:Liferay.Language.get("please-enter-a-valid-name"),title:Liferay.Language.get("error"),type:"danger"})}))};var r=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(a("commerce-frontend-js/ServiceProvider/index")),n=a("commerce-frontend-js/utilities/eventsDefinitions"),o=a("frontend-js-web")}));
//# sourceMappingURL=addCommerceInventoryWarehouse.js.map