Liferay.Loader.define("@liferay/commerce-term-web@1.0.11/js/addCommerceTermEntry",["module","exports","require","commerce-frontend-js/ServiceProvider/index","commerce-frontend-js/utilities/eventsDefinitions","frontend-js-web"],(function(e,r,t){var a;window;Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({defaultLanguageId:e,editCommerceTermEntryPortletURL:r,namespace:t}){const a=n.default.AdminOrderAPI("v1"),c=document.getElementById("".concat(t,"fm"));c.addEventListener("submit",(n=>{n.preventDefault();const s=c.querySelector("#".concat(t,"name")).value,d=c.querySelector("#".concat(t,"priority")).value,l=c.querySelector("#".concat(t,"type")).value;return a.addTerm({label:{[e]:s},name:s,priority:d,type:l}).then((e=>{const a=(0,o.createPortletURL)(r);a.searchParams.append("".concat(t,"commerceTermEntryId"),e.id),a.searchParams.append("p_auth",Liferay.authToken),window.parent.Liferay.fire(i.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"),"please-enter-a-valid-priority":Liferay.Language.get("please-enter-a-valid-priority"),"please-select-a-valid-type":Liferay.Language.get("please-select-a-valid-type")};(0,o.openToast)({message:r[e.message]||Liferay.Language.get("an-unexpected-error-occurred"),title:Liferay.Language.get("error"),type:"danger"})}))}))};var n=(a=t("commerce-frontend-js/ServiceProvider/index"))&&a.__esModule?a:{default:a},i=t("commerce-frontend-js/utilities/eventsDefinitions"),o=t("frontend-js-web")}));
//# sourceMappingURL=addCommerceTermEntry.js.map