Liferay.Loader.define("@liferay/object-web@1.0.132/js/components/ModalEditExternalReferenceCode",["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"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.ModalEditExternalReferenceCode=ModalEditExternalReferenceCode,t.default=void 0;var a=_interopRequireDefault(r("@frontend-taglib-clay$clayui/alert")),n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/button")),o=_interopRequireDefault(r("@frontend-taglib-clay$clayui/form")),l=_interopRequireDefault(r("@frontend-taglib-clay$clayui/modal")),c=r("@liferay/object-js-components-web"),i=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 r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=a?Object.getOwnPropertyDescriptor(e,n):null;o&&(o.get||o.set)?Object.defineProperty(r,n,o):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ModalEditExternalReferenceCode({externalReferenceCode:e,objectDefinitionId:t,observer:r,onClose:u,setExternalReferenceCode:f}){const[d,y]=(0,i.useState)(""),{errors:s,handleChange:b,handleSubmit:p,values:g}=(0,c.useForm)({initialValues:{externalReferenceCode:e},onSubmit:async({externalReferenceCode:e})=>{try{const r=await c.API.getObjectDefinition(t);await c.API.save("/o/object-admin/v1.0/object-definitions/".concat(t),_objectSpread(_objectSpread({},r),{},{externalReferenceCode:e})),f(e),u(),(0,c.openToast)({message:Liferay.Language.get("your-request-completed-successfully")})}catch(e){y(e.message)}},validate:({externalReferenceCode:e})=>{const t={};return""===e&&(t.externalReferenceCode=Liferay.Language.get("required")),t}});return i.default.createElement(l.default,{center:!0,observer:r},i.default.createElement(o.default,{onSubmit:p},i.default.createElement(l.default.Header,null,Liferay.Util.sub(Liferay.Language.get("edit-x"),Liferay.Language.get("external-reference-code"))),i.default.createElement(l.default.Body,null,d&&i.default.createElement(a.default,{displayType:"danger"},d),i.default.createElement(c.Input,{error:s.externalReferenceCode,feedbackMessage:Liferay.Language.get("internal-key-to-reference-the-object-definition"),id:"externalReferenceCode",label:Liferay.Language.get("external-reference-code"),name:"externalReferenceCode",onChange:b,required:!0,value:g.externalReferenceCode})),i.default.createElement(l.default.Footer,{last:i.default.createElement(n.default.Group,{key:1,spaced:!0},i.default.createElement(n.default,{displayType:"secondary",onClick:()=>u()},Liferay.Language.get("cancel")),i.default.createElement(n.default,{displayType:"primary",type:"submit"},Liferay.Language.get("save")))})))}var u=ModalEditExternalReferenceCode;t.default=u}}));
//# sourceMappingURL=ModalEditExternalReferenceCode.js.map