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