import{bW as S,bI as U,cy as v,cV as T,r as c,aA as E,aB as k,dj as w,j as e,L as P,f as F,q as s,cP as V,c7 as p,d as x,aH as b,aY as j,aJ as I,Z as C,dk as g,bG as N,bH as R,au as _,d9 as y}from"./index-C6OVXshM.js";const q=C().shape({firstname:g.label("First name"),lastname:g.label("Last name")}),A=({user:a})=>{const n=S(),m=U(),{isServiceUser:l}=v(),{data:d,isLoading:i}=T("saas_profile_url",{skip:!l}),[r,u]=c.useState({firstname:!1,lastname:!1}),{formState:{errors:f},register:h,handleSubmit:D}=E({defaultValues:{firstname:a.firstname,lastname:a.lastname},shouldUnregister:!1,resolver:k(q),reValidateMode:"onChange",mode:"onChange"}),o=a.accountType!==w.M_ACCOUNT_TYPE,L=c.useCallback(async t=>{await n.auth.updateData({data:t}),m.success({title:"Info updated",content:"Your information has been successfully updated."})},[n.auth,m]);return c.useEffect(()=>{l&&!i&&(window.location.href=d||"https://managed.hopsworks.ai/settings")},[d,i,l]),!a.email||i?e.jsx(P,{}):l?null:e.jsx(F,{width:"100%",title:"Edit profile",children:e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{children:[e.jsx(V,{firstName:a.firstname,lastName:a.lastname}),e.jsxs(s,{mt:"3px",flexDirection:"column",ml:"20px",children:[e.jsx(p,{mb:"3px",gray:!0,children:"Username"}),e.jsx(x,{primary:!0,children:a.username})]}),e.jsxs(s,{mt:"3px",flexDirection:"column",ml:"20px",children:[e.jsx(p,{mb:"3px",gray:!0,children:"Email"}),e.jsx(x,{primary:!0,children:a.email})]})]}),e.jsxs(s,{mt:"30px",children:[e.jsx(b,{label:"First name",...h("firstname"),labelProps:{mr:"20px"},disabled:o,placeholder:"First name",onChange:t=>u({...r,firstname:a.firstname!==t.target.value}),...j("firstname",f)}),e.jsx(b,{label:"Last name",...h("lastname"),disabled:o,labelProps:{mr:"20px"},placeholder:"Last name",onChange:t=>u({...r,lastname:a.lastname!==t.target.value}),...j("lastname",f)})]}),!o&&e.jsx(I,{disabled:!r.firstname&&!r.lastname,onClick:D(L),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},M=C().shape({name:y.label("Name"),login:y.label("Description")}),Y=()=>{N(R.accountSettings);const{currentData:a,isLoading:n}=_();return n?e.jsx(P,{}):e.jsx(s,{flexDirection:"column",alignItems:"center",children:e.jsx(A,{user:a})})};export{Y as default,M as schema};
