import{a7 as C,cI as x,b1 as D,a_ as L,c9 as P,aL as T,r as c,an as v,ao as w,cJ as F,j as e,a$ as E,E as I,Q as s,cs as V,bf as p,g,aH as j,ay as b,aU as _,cy as y,aY as k,cK as N,aZ as Q}from"./index-ea7817a2.js";const R=C().shape({firstname:x.label("First name"),lastname:x.label("Last name")}),Y=({user:a})=>{const n=D(),m=L(),{isServiceUser:l}=P(),{data:d,isLoading:i}=T("saas_profile_url",{skip:!l}),[r,u]=c.useState({firstname:!1,lastname:!1}),{formState:{errors:f},register:h,handleSubmit:S}=v({defaultValues:{firstname:a.firstname,lastname:a.lastname},shouldUnregister:!1,resolver:w(R),reValidateMode:"onChange",mode:"onChange"}),o=a.accountType!==F.M_ACCOUNT_TYPE,U=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(E,{}):l?null:e.jsx(I,{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(g,{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(g,{primary:!0,children:a.email})]})]}),e.jsxs(s,{mt:"30px",children:[e.jsx(j,{label:"First name",...h("firstname"),labelProps:{mr:"20px"},disabled:o,placeholder:"First name",onChange:t=>u({...r,firstname:a.firstname!==t.target.value}),...b("firstname",f)}),e.jsx(j,{label:"Last name",...h("lastname"),disabled:o,labelProps:{mr:"20px"},placeholder:"Last name",onChange:t=>u({...r,lastname:a.lastname!==t.target.value}),...b("lastname",f)})]}),!o&&e.jsx(_,{disabled:!r.firstname&&!r.lastname,onClick:S(U),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},G=C().shape({name:y.label("Name"),login:y.label("Description")}),J=()=>{k(Q.accountSettings);const{currentData:a,isLoading:n}=N();return n?e.jsx(E,{}):e.jsx(s,{flexDirection:"column",alignItems:"center",children:e.jsx(Y,{user:a})})};export{J as default,G as schema};
