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