Liferay.Loader.define("layout-template-admin-web@2.0.75/js/modal/DisplayPageModal.es",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/modal","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./DisplayPageModalForm.es"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=a.DisplayPageModal=void 0;var r=s(t("@frontend-taglib-clay$clayui/alert")),n=s(t("@frontend-taglib-clay$clayui/button")),l=u(t("@frontend-taglib-clay$clayui/modal")),o=t("frontend-js-web"),c=(s(t("liferay!frontend-js-react-web$prop-types")),u(t("liferay!frontend-js-react-web$react"))),d=s(t("./DisplayPageModalForm.es"));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function u(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var a=i();if(a&&a.has(e))return a.get(e);var t={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(t,n,l):t[n]=e[n]}return t.default=e,a&&a.set(e,t),t}function s(e){return e&&e.__esModule?e:{default:e}}const e=e=>{const{formSubmitURL:a,onClose:t}=e,i=(0,c.useRef)(),[u,s]=(0,c.useState)(null),[f,p]=(0,c.useState)(!1),{observer:y}=(0,l.useModal)({onClose:t}),m=(0,c.useCallback)((a=>{const{elements:t}=a,r={},n=Liferay.Language.get("this-field-is-required");t["".concat(e.namespace,"name")].value||(r.name=n);0===t["".concat(e.namespace,"classNameId")].selectedIndex&&(r.classNameId=n);const l=t["".concat(e.namespace,"classTypeId")];return l&&0===l.selectedIndex&&(r.classTypeId=n),r}),[e.namespace]),g=(0,c.useCallback)((e=>{e.preventDefault();const r=m(i.current);0===Object.keys(r).length?(p(!0),(0,o.fetch)(a,{body:new FormData(i.current),method:"POST"}).then((e=>e.json())).then((e=>{e.error?(p(!1),s(e.error)):e.redirectURL&&(0,o.navigate)(e.redirectURL,{beforeScreenFlip:t})})).catch((()=>s({other:Liferay.Language.get("an-unexpected-error-occurred-while-creating-the-display-page")})))):s(r)}),[a,t,m]),b=y.mutation;return c.default.createElement(l.default,{observer:y,size:"md"},c.default.createElement(l.default.Header,null,e.title),c.default.createElement(l.default.Body,null,u&&u.other&&c.default.createElement(r.default,{displayType:"danger",onClose:()=>{},title:Liferay.Language.get("error")},u.other),b&&c.default.createElement(d.default,{displayPageName:e.displayPageName,error:u,mappingTypes:e.mappingTypes,namespace:e.namespace,onSubmit:g,ref:i})),c.default.createElement(l.default.Footer,{last:c.default.createElement(n.default.Group,{spaced:!0},c.default.createElement(n.default,{displayType:"secondary",onClick:t},Liferay.Language.get("cancel")),c.default.createElement(n.default,{displayType:"primary",onClick:g},f&&c.default.createElement("span",{className:"inline-item inline-item-before"},c.default.createElement("span",{"aria-hidden":"true",className:"loading-animation"})),Liferay.Language.get("save")))}))};a.DisplayPageModal=e;var f=e;a.default=f}}));
//# sourceMappingURL=DisplayPageModal.es.js.map