Liferay.Loader.define("@liferay/object-web@1.0.145/js/components/ModalBasicWithFieldName",["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,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.ModalBasicWithFieldName=ModalBasicWithFieldName,a.default=void 0;var r=_interopRequireDefault(t("@frontend-taglib-clay$clayui/alert")),l=_interopRequireDefault(t("@frontend-taglib-clay$clayui/button")),n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/form")),i=_interopRequireDefault(t("@frontend-taglib-clay$clayui/modal")),u=t("@liferay/object-js-components-web"),o=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={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var n=r?Object.getOwnPropertyDescriptor(e,l):null;n&&(n.get||n.set)?Object.defineProperty(t,l,n):t[l]=e[l]}t.default=e,a&&a.set(e,t);return t}(t("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}}const e=Liferay.ThemeDisplay.getDefaultLanguageId();function ModalBasicWithFieldName({apiURL:a,inputId:t,label:d,observer:c,onClose:f}){const[y,s]=(0,o.useState)(""),{errors:m,handleChange:p,handleSubmit:g,values:b}=(0,u.useForm)({initialValues:{name:{[e]:""}},onSubmit:async({name:t})=>{try{await u.API.save(a,{name:{[e]:t}},"POST"),f(),window.location.reload()}catch(e){s(e.message)}},validate:({name:a})=>{const t={};return""===a[e]&&(t.name=Liferay.Language.get("required")),t}});return o.default.createElement(o.default.Fragment,null,o.default.createElement(i.default,{observer:c},o.default.createElement(n.default,{onSubmit:g},o.default.createElement(i.default.Header,null,d),o.default.createElement(i.default.Body,null,y&&o.default.createElement(r.default,{displayType:"danger"},y),o.default.createElement(u.Input,{error:m.name,id:t,label:Liferay.Language.get("name"),name:"name",onChange:p,required:!0,value:b.name[e]})),o.default.createElement(i.default.Footer,{last:o.default.createElement(l.default.Group,{key:1,spaced:!0},o.default.createElement(l.default,{displayType:"secondary",onClick:f},Liferay.Language.get("cancel")),o.default.createElement(l.default,{displayType:"primary",type:"submit"},Liferay.Language.get("save")))}))))}var d=ModalBasicWithFieldName;a.default=d}}));
//# sourceMappingURL=ModalBasicWithFieldName.js.map