Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ModalAddListTypeDefinition",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/modal","@liferay/object-js-components-web","liferay!frontend-js-react-web$react","../utils/constants"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/alert")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/form")),i=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/modal")),u=a("@liferay/object-js-components-web"),o=_interopRequireWildcard(a("liferay!frontend-js-react-web$react")),d=a("../utils/constants");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const ModalAddListTypeDefinition=({apiURL:e,observer:t,onClose:a})=>{const c={name_i18n:{[d.defaultLanguageId]:""}},[f,s]=(0,o.useState)(""),{errors:y,handleSubmit:p,setValues:g,values:m}=(0,u.useForm)({initialValues:c,onSubmit:async t=>{try{await u.API.save(e,t,"POST"),a(),window.location.reload()}catch(e){s(e.message)}},validate:e=>{const t={};return e.name_i18n[d.defaultLanguageId]||(t.name_i18n=u.REQUIRED_MSG),t}});return o.default.createElement(i.default,{observer:t},o.default.createElement(l.default,{onSubmit:p},o.default.createElement(i.default.Header,null,Liferay.Language.get("new-picklist")),o.default.createElement(i.default.Body,null,f&&o.default.createElement(n.default,{displayType:"danger"},f),o.default.createElement(u.Input,{error:y.name_i18n,id:"listTypeDefinitionName",label:Liferay.Language.get("name"),name:"name_i18n",onChange:({target:{value:e}})=>g({name_i18n:{[d.defaultLanguageId]:e}}),required:!0,value:m.name_i18n[d.defaultLanguageId]})),o.default.createElement(i.default.Footer,{last:o.default.createElement(r.default.Group,{key:1,spaced:!0},o.default.createElement(r.default,{displayType:"secondary",onClick:()=>a()},Liferay.Language.get("cancel")),o.default.createElement(r.default,{displayType:"primary",type:"submit"},Liferay.Language.get("save")))})))};var _default=({apiURL:e})=>{const[t,a]=(0,o.useState)(!1),{observer:n,onClose:r}=(0,i.useModal)({onClose:()=>a(!1)});return(0,o.useEffect)((()=>(Liferay.on("addListTypeDefinition",(()=>a(!0))),()=>{Liferay.detach("addListTypeDefinition",(()=>a(!0)))})),[]),o.default.createElement(i.ClayModalProvider,null,t&&o.default.createElement(ModalAddListTypeDefinition,{apiURL:e,observer:n,onClose:r}))};t.default=_default}}));
//# sourceMappingURL=ModalAddListTypeDefinition.js.map