"use strict";var b=Object.create;var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var T=Object.getPrototypeOf;var h=Object.prototype.hasOwnProperty;var u=(a,s)=>i(a,"name",{value:s,configurable:true});var S=(a,s)=>{for(var e in s)i(a,e,{get:s[e],enumerable:true})};var c=(a,s,e,r)=>{if(s&&typeof s==="object"||typeof s==="function"){for(let n of P(s))if(!h.call(a,n)&&n!==e)i(a,n,{get:()=>s[n],enumerable:!(r=w(s,n))||r.enumerable})}return a};var d=(a,s,e)=>(e=a!=null?b(T(a)):{},c(s||!a||!a.__esModule?i(e,"default",{value:a,enumerable:true}):e,a));var E=a=>c(i({},"__esModule",{value:true}),a);var I={};S(I,{default:()=>F});module.exports=E(I);var m=require("react/jsx-runtime");var l=require("mobx-react");var g=require("react");var p=require("react-intl");var y=d(require("../../components/settings/user/EditUserForm"));var v=d(require("../../components/util/ErrorBoundary"));var M=d(require("../../lib/Form"));var o=require("../../helpers/validation-helpers");const t=(0,p.defineMessages)({firstname:{id:"settings.user.form.firstname",defaultMessage:"First Name"},lastname:{id:"settings.user.form.lastname",defaultMessage:"Last Name"},email:{id:"settings.user.form.email",defaultMessage:"Email"},accountTypeLabel:{id:"settings.user.form.accountType.label",defaultMessage:"Account type"},accountTypeIndividual:{id:"settings.user.form.accountType.individual",defaultMessage:"Individual"},accountTypeNonProfit:{id:"settings.user.form.accountType.non-profit",defaultMessage:"Non-Profit"},accountTypeCompany:{id:"settings.user.form.accountType.company",defaultMessage:"Company"},currentPassword:{id:"settings.user.form.currentPassword",defaultMessage:"Current password"},newPassword:{id:"settings.user.form.newPassword",defaultMessage:"New password"}});class f extends g.Component{componentWillUnmount(){this.props.actions.user.resetStatus()}onSubmit(s){const{update:e}=this.props.actions.user;e({userData:s});document.querySelector("#form")?.scrollIntoView({behavior:"smooth"})}prepareForm(s){const{intl:e}=this.props;const r={fields:{firstname:{label:e.formatMessage(t.firstname),placeholder:e.formatMessage(t.firstname),value:s.firstname,validators:[o.required]},lastname:{label:e.formatMessage(t.lastname),placeholder:e.formatMessage(t.lastname),value:s.lastname,validators:[o.required]},email:{label:e.formatMessage(t.email),placeholder:e.formatMessage(t.email),value:s.email,validators:[o.required,o.email]},accountType:{value:s.accountType,validators:[o.required],label:e.formatMessage(t.accountTypeLabel),options:[{value:"individual",label:e.formatMessage(t.accountTypeIndividual)},{value:"non-profit",label:e.formatMessage(t.accountTypeNonProfit)},{value:"company",label:e.formatMessage(t.accountTypeCompany)}]},organization:{label:e.formatMessage(t.accountTypeCompany),placeholder:e.formatMessage(t.accountTypeCompany),value:s.organization},oldPassword:{label:e.formatMessage(t.currentPassword),type:"password",validators:[(0,o.minLength)(6)]},newPassword:{label:e.formatMessage(t.newPassword),type:"password",validators:[(0,o.minLength)(6)]}}};return new M.default(r)}render(){const{user:s}=this.props.stores;if(s.getUserInfoRequest.isExecuting){return(0,m.jsx)("div",{children:"Loading..."})}const e=this.prepareForm(s.data);return(0,m.jsx)(v.default,{children:(0,m.jsx)(y.default,{status:s.actionStatus,form:e,isSaving:s.updateUserInfoRequest.isExecuting,onSubmit:r=>this.onSubmit(r)})})}}u(f,"EditUserScreen");var F=(0,p.injectIntl)((0,l.inject)("stores","actions")((0,l.observer)(f)));
