Liferay.Loader.define("commerce-frontend-js@4.0.75/components/account_selector/views/AccountCreationModal",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/modal","frontend-js-web","liferay!frontend-js-react-web$react","./AccountCreationModalBody"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function AccountCreationModal({accountTypes:t,closeModal:a,handleAccountChange:i,observer:d}){const[f,s]=(0,l.useState)({description:"",externalReferenceCode:"",name:"",organizations:[],taxId:"",type:t[0]});return l.default.createElement(o.default,{center:!0,className:"commerce-modal",observer:d},l.default.createElement(o.default.Header,null,Liferay.Language.get("create-new-account")),l.default.createElement(r.default,{onSubmit:t=>{t.preventDefault();const n=f.organizations.map((({value:e})=>e));(0,c.fetch)(e,{body:JSON.stringify({description:f.description,externalReferenceCode:f.externalReferenceCode,id:f.taxId,name:f.name,organizationIds:n,type:f.type}),headers:{"Content-Type":"application/json"},method:"POST"}).then((e=>e.json())).then((e=>{i(e),a()})).catch((e=>console.error(e)))}},l.default.createElement(u.default,{accountData:f,accountTypes:t,setAccountData:s}),l.default.createElement(o.default.Footer,{last:l.default.createElement(n.default.Group,{spaced:!0},l.default.createElement(n.default,{displayType:"secondary",onClick:a},Liferay.Language.get("cancel")),l.default.createElement(n.default,{type:"submit"},Liferay.Language.get("create")))})))};var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/form")),o=_interopRequireDefault(a("@frontend-taglib-clay$clayui/modal")),c=a("frontend-js-web"),l=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 a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o=n?Object.getOwnPropertyDescriptor(e,r):null;o&&(o.get||o.set)?Object.defineProperty(a,r,o):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),u=_interopRequireDefault(a("./AccountCreationModalBody"));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="/o/headless-admin-user/v1.0/accounts"}}));
//# sourceMappingURL=AccountCreationModal.js.map