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