Liferay.Loader.define("@liferay/commerce-order-web@5.0.61/js/addCommerceOrderType",["module","exports","require","commerce-frontend-js/ServiceProvider/index","commerce-frontend-js/utilities/eventsDefinitions","frontend-js-web"],(function(e,r,a){var t;window;Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({defaultLanguageId:e,editCommerceOrderTypePortletURL:r,namespace:a}){const t=n.default.AdminOrderAPI("v1"),c=document.getElementById("".concat(a,"fm"));c.addEventListener("submit",(n=>{n.preventDefault();const d=c.querySelector("#".concat(a,"description")).value,s=c.querySelector("#".concat(a,"name")).value;if(s)return t.addOrderType({description:{[e]:d},name:{[e]:s}}).then((e=>{const t=(0,i.createPortletURL)(r);t.searchParams.append("".concat(a,"commerceOrderTypeId"),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 r={"please-enter-a-valid-name":Liferay.Language.get("please-enter-a-valid-name")};(0,i.openToast)({message:r[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=a("commerce-frontend-js/ServiceProvider/index"))&&t.__esModule?t:{default:t},o=a("commerce-frontend-js/utilities/eventsDefinitions"),i=a("frontend-js-web")}));
//# sourceMappingURL=addCommerceOrderType.js.map