Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ViewObjectDefinitions/ModalAddFolder",["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","frontend-js-web","liferay!frontend-js-react-web$react","../../utils/constants","./objectDefinitionUtil"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.ModalAddFolder=function ModalAddFolder({handleOnClose:e}){var a;const[t,s]=(0,d.useState)(""),{observer:b,onClose:y}=(0,o.useModal)({onClose:()=>e()}),m={label:"",name:void 0},{errors:g,handleChange:p,handleSubmit:j,values:v}=(0,i.useForm)({initialValues:m,onSubmit:async({label:e,name:a})=>{const t={label:{[c.defaultLanguageId]:e},name:a||(0,f.normalizeName)(e)};try{await i.API.save("/o/object-admin/v1.0/object-folders",t,"POST"),y(),(0,i.openToast)({message:(0,u.sub)(Liferay.Language.get("x-was-created-successfully"),"<strong>".concat(e,"</strong>")),type:"success"}),setTimeout((()=>window.location.reload()),1e3)}catch(e){s(e.message)}},validate:e=>{var a;const t={};return e.label||(t.label=i.REQUIRED_MSG),(null!==(a=e.name)&&void 0!==a?a:e.label)||(t.name=i.REQUIRED_MSG),t}});return d.default.createElement(o.ClayModalProvider,null,d.default.createElement(o.default,{observer:b},d.default.createElement(n.default,{onSubmit:j},d.default.createElement(o.default.Header,null,Liferay.Language.get("new-object-folder")),d.default.createElement(o.default.Body,null,t&&d.default.createElement(l.default,{displayType:"danger"},t),d.default.createElement(i.Input,{error:g.label,id:"folderLabel",label:Liferay.Language.get("label"),name:"label",onChange:p,required:!0,value:v.label}),d.default.createElement(i.Input,{error:g.name,id:"folderName",label:Liferay.Language.get("name"),name:"name",onChange:p,required:!0,value:null!==(a=v.name)&&void 0!==a?a:(0,f.normalizeName)(v.label)})),d.default.createElement(o.default.Footer,{last:d.default.createElement(r.default.Group,{key:1,spaced:!0},d.default.createElement(r.default,{displayType:"secondary",onClick:()=>y()},Liferay.Language.get("cancel")),d.default.createElement(r.default,{displayType:"primary",type:"submit"},Liferay.Language.get("create-folder")))}))))};var l=_interopRequireDefault(t("@frontend-taglib-clay$clayui/alert")),r=_interopRequireDefault(t("@frontend-taglib-clay$clayui/button")),n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/form")),o=_interopRequireWildcard(t("@frontend-taglib-clay$clayui/modal")),i=t("@liferay/object-js-components-web"),u=t("frontend-js-web"),d=_interopRequireWildcard(t("liferay!frontend-js-react-web$react")),c=t("../../utils/constants"),f=t("./objectDefinitionUtil");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 a=_getRequireWildcardCache();if(a&&a.has(e))return a.get(e);var t={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(t,r,n):t[r]=e[r]}return t.default=e,a&&a.set(e,t),t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=ModalAddFolder.js.map