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