Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ViewObjectDefinitions/ModalEditFolder",["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"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.ModalEditFolder=function ModalEditFolder({externalReferenceCode:e,folderID:a,handleOnClose:t,initialLabel:f,name:s}){const[b,y]=(0,u.useState)(""),[g,p]=(0,u.useState)(c.defaultLanguageId),{observer:m,onClose:L}=(0,o.useModal)({onClose:()=>t()}),{errors:R,handleChange:C,handleSubmit:j,setValues:E,values:v}=(0,i.useForm)({initialValues:{externalReferenceCode:e,label:f,name:s},onSubmit:async e=>{const t=e;try{await i.API.save("/o/object-admin/v1.0/object-folders/".concat(a),t,"PATCH"),L(),(0,i.openToast)({message:(0,d.sub)(Liferay.Language.get("x-was-saved-successfully"),"<strong>".concat((0,i.getLocalizableLabel)(c.defaultLanguageId,t.label,t.name),"</strong>")),type:"success"}),setTimeout((()=>window.location.reload()),1e3)}catch(e){y(e.message)}},validate:e=>{const a={};return(0,i.invalidateLocalizableLabelRequired)(e.label)&&(a.label=i.REQUIRED_MSG),e.externalReferenceCode||(a.externalReferenceCode=i.REQUIRED_MSG),a}});return u.default.createElement(o.ClayModalProvider,null,u.default.createElement(o.default,{observer:m},u.default.createElement(n.default,{onSubmit:j},u.default.createElement(o.default.Header,null,Liferay.Language.get("edit-label-and-erc")),u.default.createElement(o.default.Body,null,b&&u.default.createElement(l.default,{displayType:"danger"},b),u.default.createElement(i.InputLocalized,{error:R.label,label:Liferay.Language.get("label"),onChange:e=>E({label:e}),onSelectedLocaleChange:p,required:!0,selectedLocale:g,translations:v.label}),u.default.createElement(i.Input,{disabled:!0,id:"folderName",label:Liferay.Language.get("name"),name:"name",required:!0,value:v.name}),u.default.createElement(i.Input,{error:R.externalReferenceCode,feedbackMessage:Liferay.Language.get("unique-key-for-referencing-the-object-folder"),id:"externalReferenceCode",label:Liferay.Language.get("external-reference-code"),name:"externalReferenceCode",onChange:C,required:!0,value:v.externalReferenceCode})),u.default.createElement(o.default.Footer,{last:u.default.createElement(r.default.Group,{key:1,spaced:!0},u.default.createElement(r.default,{displayType:"secondary",onClick:()=>L()},Liferay.Language.get("cancel")),u.default.createElement(r.default,{displayType:"primary",type:"submit"},Liferay.Language.get("save")))}))))};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"),d=t("frontend-js-web"),u=_interopRequireWildcard(t("liferay!frontend-js-react-web$react")),c=t("../../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 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=ModalEditFolder.js.map